# godemo **Repository Path**: fromdtor/godemo ## Basic Information - **Project Name**: godemo - **Description**: 演示使用go起新项目,包括 1.系统包导入和使用 2.从项目其他文件导入和使用 3.第三方包的导入和使用 - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-08 - **Last Updated**: 2022-07-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go项目 ## step 1 ``` ➜ mkdir godemo && cd godemo ➜ touch README.md main.go ➜ go mod init godemo ``` ## step 2 使用go get安装第三方包 ``` ➜ go get github.com/satori/go.uuid ``` 这个命令会将包安装到系统的GOPATH,并且会修改go.mod和go.sum文件 ``` ➜ cat go.mod module godemo go 1.18 require github.com/satori/go.uuid v1.2.0 // indirect ``` ``` ➜ cat go.sum github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= ``` ``` ls ~/go/pkg/mod/github.com/satori/go.uuid@v1.2.0/ LICENSE codec_test.go sql.go uuid_test.go README.md generator.go sql_test.go codec.go generator_test.go uuid.go ``` ## step 3 直接运行 ``` ➜ godemo go run main.go this prints from sys module this prints from submod.sub1 UUIDv4: eddf906d-aab3-4bf9-9b0f-022ddac48043 ``` 编译运行 ``` ➜ godemo go build ➜ godemo ./godemo this prints from sys module this prints from submod.sub1 UUIDv4: f9c14e9e-13a5-4541-9058-64b333ab8a23 ```