当前位置: 首页 > news >正文

全国加盟网站官网住房城乡建设部门门户网站

全国加盟网站官网,住房城乡建设部门门户网站,网站建设项目怎么写,优化方案英语目录 一、Go Module 1、开启Go Module 2、Go Module基本操作 3、使用GoLand创建Go Module项目 4、GoLand配置File Watchers 一、Go Module Go Module包管理工具----相当于Maven 1.11版本引入 1.12版本正式支持 告别GOPATH#xff0c;使用Go Module管理项目#xff0c…目录 一、Go Module 1、开启Go Module 2、Go Module基本操作 3、使用GoLand创建Go Module项目 4、GoLand配置File Watchers 一、Go Module Go Module包管理工具----相当于Maven 1.11版本引入 1.12版本正式支持 告别GOPATH使用Go Module管理项目就不需要非得把项目放到GOPATH SRC目录下你可以在你磁盘的任何位置新建一个项目 C:\Users\Administratorgo env set GO111MODULE set GOARCHamd64 set GOBIN set GOCACHEC:\Users\Administrator\AppData\Local\go-build set GOENVC:\Users\Administrator\AppData\Roaming\go\env set GOEXE.exe set GOEXPERIMENT set GOFLAGS set GOHOSTARCHamd64 set GOHOSTOSwindows set GOINSECURE set GOMODCACHEC:\Users\Administrator\go\pkg\mod set GONOPROXY set GONOSUMDB set GOOSwindows set GOPATHC:\Users\Administrator\go set GOPRIVATE set GOPROXYhttps://proxy.golang.org,direct set GOROOTC:\Program Files\Go set GOSUMDBsum.golang.org set GOTMPDIR set GOTOOLDIRC:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS set GOVERSIONgo1.20.6 set GCCGOgccgo set GOAMD64v1 set ARar set CCgcc set CXXg set CGO_ENABLED0 set GOMODNUL set GOWORK set CGO_CFLAGS-O2 -g set CGO_CPPFLAGS set CGO_CXXFLAGS-O2 -g set CGO_FFLAGS-O2 -g set CGO_LDFLAGS-O2 -g set PKG_CONFIGpkg-config set GOGCCFLAGS-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length0 -fdebug-prefix-mapC:\Users\ADMINI~1\AppData\Local\Temp\go-build3162599993/tmp/go-build -gno-record-gcc-switches 1、开启Go Module 1、修改环境变量 C:\Users\Administratorgo env -w GO111MODULEonC:\Users\Administratorgo env -w GOPROXYhttps://goproxy.cn,direct#GO111MODULE 三种值 GO111MODULEoff go命令行将不会支持module功能寻找依赖包的方式将会沿用旧版本那种 通过vendor目录或GOPATH模式来查找 GO111MODULEon go命令将会使用module也不会取GOPATH目录下查找 GO111MODULEauto 默认值go命令将会根据当前目录来决定是否启用module功能2、命令行方式创建Go Module项目 mkdir projectname cd projectname go mod init projectname #使用GoLand打开工程 #S 演示 D:\GO_workspace_webmkdir test_modelD:\GO_workspace_webcd test_modelD:\GO_workspace_web\test_modelgo mod init test_model go: creating new go.mod: module test_model#此时test_model下会创建go.mod文件 #使用GoLand打开工程 #E 演示 go.mod内容 module test_modelgo 1.20在GoLand软件的Terminal中输入 go get -u github.com/gin-gonic/gin#执行信息如下 PS D:\GO_workspace_web\test_model go get -u github.com/gin-gonic/gin go: downloading github.com/gin-gonic/gin v1.9.1 go: downloading github.com/gin-contrib/sse v0.1.0 go: downloading golang.org/x/net v0.10.0 go: downloading github.com/mattn/go-isatty v0.0.19 go: downloading github.com/pelletier/go-toml/v2 v2.0.8 go: downloading github.com/go-playground/validator/v10 v10.14.0 go: downloading github.com/ugorji/go/codec v1.2.11 go: downloading google.golang.org/protobuf v1.30.0 go: downloading gopkg.in/yaml.v3 v3.0.1 go: downloading github.com/bytedance/sonic v1.9.1 go: downloading github.com/pelletier/go-toml v1.9.5 go: downloading github.com/goccy/go-json v0.10.2 go: downloading github.com/pelletier/go-toml/v2 v2.0.9 go: downloading github.com/go-playground/validator/v10 v10.15.0 go: downloading github.com/ugorji/go v1.2.11 go: downloading github.com/json-iterator/go v1.1.12 go: downloading github.com/go-playground/validator v9.31.0incompatible go: downloading golang.org/x/sys v0.8.0 go: downloading google.golang.org/protobuf v1.31.0 go: downloading golang.org/x/net v0.14.0 go: downloading github.com/bytedance/sonic v1.10.0 go: downloading github.com/gabriel-vasile/mimetype v1.4.2 go: downloading github.com/go-playground/universal-translator v0.18.1 go: downloading github.com/leodido/go-urn v1.2.4 go: downloading golang.org/x/crypto v0.9.0 go: downloading golang.org/x/text v0.9.0 go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd go: downloading github.com/modern-go/reflect2 v1.0.2 go: downloading golang.org/x/sys v0.11.0 go: downloading github.com/go-playground/locales v0.14.1 go: downloading golang.org/x/crypto v0.12.0 go: downloading github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 go: downloading golang.org/x/text v0.12.0 go: downloading golang.org/x/arch v0.3.0 go: downloading github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d go: downloading github.com/twitchyliquid64/golang-asm v0.15.1 go: downloading golang.org/x/arch v0.4.0 go: downloading github.com/klauspost/cpuid/v2 v2.2.4 go: downloading github.com/klauspost/cpuid/v2 v2.2.5 go: downloading github.com/klauspost/cpuid v1.3.1 go: downloading github.com/chenzhuoyu/iasm v0.9.0 go: added github.com/bytedance/sonic v1.10.0 go: added github.com/twitchyliquid64/golang-asm v0.15.1 go: added github.com/ugorji/go/codec v1.2.11 go: added golang.org/x/arch v0.4.0 go: added golang.org/x/crypto v0.12.0 go: added golang.org/x/net v0.14.0 go: added golang.org/x/sys v0.11.0 go: added golang.org/x/text v0.12.0 go: added google.golang.org/protobuf v1.31.0 go: added gopkg.in/yaml.v3 v3.0.1 PS D:\GO_workspace_web\test_model此时的go.mod内容 module test_modelgo 1.20require (github.com/bytedance/sonic v1.10.0 // indirectgithub.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirectgithub.com/chenzhuoyu/iasm v0.9.0 // indirectgithub.com/gabriel-vasile/mimetype v1.4.2 // indirectgithub.com/gin-contrib/sse v0.1.0 // indirectgithub.com/gin-gonic/gin v1.9.1 // indirectgithub.com/go-playground/locales v0.14.1 // indirectgithub.com/go-playground/universal-translator v0.18.1 // indirectgithub.com/go-playground/validator/v10 v10.15.0 // indirectgithub.com/goccy/go-json v0.10.2 // indirectgithub.com/json-iterator/go v1.1.12 // indirectgithub.com/klauspost/cpuid/v2 v2.2.5 // indirectgithub.com/leodido/go-urn v1.2.4 // indirectgithub.com/mattn/go-isatty v0.0.19 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectgithub.com/modern-go/reflect2 v1.0.2 // indirectgithub.com/pelletier/go-toml/v2 v2.0.9 // indirectgithub.com/twitchyliquid64/golang-asm v0.15.1 // indirectgithub.com/ugorji/go/codec v1.2.11 // indirectgolang.org/x/arch v0.4.0 // indirectgolang.org/x/crypto v0.12.0 // indirectgolang.org/x/net v0.14.0 // indirectgolang.org/x/sys v0.11.0 // indirectgolang.org/x/text v0.12.0 // indirectgoogle.golang.org/protobuf v1.31.0 // indirectgopkg.in/yaml.v3 v3.0.1 // indirect )编写main.go package mainimport (github.com/gin-gonic/gin )func main() {r : gin.Default()r.GET(/test, func(c *gin.Context) {c.JSON(200, gin.H{msg: test success,})})r.Run() } 运行 访问测试http://localhost:8080/test 2、Go Module基本操作 D:\GO_workspace_web\test_modelgo mod help #查看帮助 Go mod provides access to operations on modules.Note that support for modules is built into all the go commands, not just go mod. For example, day-to-day adding, removing, upgrading, and downgrading of dependencies should be done using go get. See go help modules for an overview of module functionality.Usage:go mod command [arguments]The commands are:download download modules to local cacheedit edit go.mod from tools or scriptsgraph print module requirement graphinit initialize new module in current directorytidy add missing and remove unused modulesvendor make vendored copy of dependenciesverify verify dependencies have expected contentwhy explain why packages or modules are neededUse go help mod command for more information about a command. 初始化一个module模块名为项目名 go mod init projectname 下载module到本地cache路径为go env中的GOMODCACHE go mod download 通过工具或脚本剪辑go.mod文件选项有-json、-require和-exclude可以使用帮助go help mod edit D:\GO_workspace_web\test_modelgo help mod edit usage: go mod edit [editing flags] [-fmt|-print|-json] [go.mod]Edit provides a command-line interface for editing go.mod, for use primarily by tools or scripts. It reads only go.mod; it does not look up information about the modules involved. By default, edit reads and writes the go.mod file of the main module, but a different target file can be specified after the editing flags.The editing flags specify a sequence of editing operations.The -fmt flag reformats the go.mod file without making other changes. This reformatting is also implied by any other modifications that use or rewrite the go.mod file. The only time this flag is needed is if no other flags are specified, as in go mod edit -fmt.The -module flag changes the modules path (the go.mod files module line).The -requirepathversion and -droprequirepath flags add and drop a requirement on the given module path and version. Note that -require overrides any existing requirements on path. These flags are mainly for tools that understand the module graph. Users should prefer go get pathversion or go get pathnone, which make other go.mod adjustments as needed to satisfy constraints imposed by other modules.The -excludepathversion and -dropexcludepathversion flags add and drop an exclusion for the given module path and version. Note that -excludepathversion is a no-op if that exclusion already exists.The -replaceold[v]new[v] flag adds a replacement of the given module path and version pair. If the v in oldv is omitted, a replacement without a version on the left side is added, which applies to all versions of the old module path. If the v in newv is omitted, the new path should be a local module root directory, not a module path. Note that -replace overrides any redundant replacements for old[v], so omitting v will drop existing replacements for specific versions. ...... 以文本模式打印模块需求图 go mod graphD:\GO_workspace_web\test_modelgo mod graph #在项目文件夹下执行 test_model github.com/bytedance/sonicv1.10.0 test_model github.com/chenzhuoyu/base64xv0.0.0-20230717121745-296ad89f973d test_model github.com/chenzhuoyu/iasmv0.9.0 test_model github.com/gabriel-vasile/mimetypev1.4.2 test_model github.com/gin-contrib/ssev0.1.0 test_model github.com/gin-gonic/ginv1.9.1 test_model github.com/go-playground/localesv0.14.1 test_model github.com/go-playground/universal-translatorv0.18.1 test_model github.com/go-playground/validator/v10v10.15.0 .... 添加缺失或者删除没有使用的modules go mod tidy 在本地生成vendor目录(旧方式) go mod vendor 验证依赖是否正确 go mod verifyD:\GO_workspace_web\test_modelgo mod verify all modules verified 查找依赖 go mod whyD:\GO_workspace_web\test_modelgo mod why go: downloading github.com/stretchr/testify v1.8.4 go: downloading github.com/google/go-cmp v0.5.5 go: downloading github.com/davecgh/go-spew v1.1.1 go: downloading github.com/go-playground/assert/v2 v2.2.0 go: downloading gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 go: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 go: downloading github.com/pmezard/go-difflib v1.0.0 # test_model test_model 3、使用GoLand创建Go Module项目 1、File---New---Project.... 有Go modules就选择没有就选择Go 点击Create创建会自动创建go.mod文件如下图 其他操作和上面命令行那种方式一样的操作即可。 4、GoLand配置File Watchers File---Settings--Tools---File Watchers,选择按照如下配置go fmt和goimports Golang学习深入(一) 干我们这行啥时候懈怠就意味着长进的停止长进的停止就意味着被淘汰只能往前冲直到凤凰涅槃的一天
http://www.w-s-a.com/news/447375/

相关文章:

  • 做外贸网站需要什么卡网站建设公司怎样
  • 网站关键词密度怎么计算的中文版wordpress
  • asp网站建设教程如何在线上推广自己的产品
  • 电脑网站你懂我意思正能量济南网站建设公司熊掌号
  • 杂志社网站建设萧山区网站建设
  • 电商网站前端制作分工网站怎做百度代码统计
  • 免费的html大作业网站网站开发心得500字
  • 临时工找工作网站做美缝帮别人做非法网站
  • 深圳网站建设 设计创公司新昌网站开发
  • 唐山教育平台网站建设上海装修网官网
  • 一个公司做多个网站什么行业愿意做网站
  • 成都龙泉建设网站免费域名app官方下载
  • xss网站怎么搭建如何用wordpress站群
  • 怎样做网站外链supercell账号注册网站
  • 阿里巴巴网站是用什么技术做的哪些网站做推广比较好
  • 做网站go和python手机如何创网站
  • 网站开发进修网站做301将重定向到新域名
  • 公司网站开发费用账务处理ucenter wordpress
  • 六站合一的优势少儿编程机构
  • 软件开发与网站开发学做美食网站哪个好
  • 网站搜索 收录优化百度推广页面投放
  • 响应式网站的优点浙江省网站域名备案
  • 网站安全 扫描深圳被点名批评
  • 在哪个网站可以一对一做汉教网站优化策略
  • 龙岩做网站的顺企网宁波网站建设
  • 昆山网站建设河北连锁餐厅vi设计公司
  • 新蔡县住房和城乡建设局网站南昌租房网地宝网
  • 南宁做网站费用iis编辑网站绑定
  • 家用宽带做网站服务器建网站费用明细
  • 电商 网站 降低 跳出率 措施 效果书画院网站模板