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

六安市住房和城乡建设委员会网站6合肥网站优化方案

六安市住房和城乡建设委员会网站6,合肥网站优化方案,上海网站制作,有什么类似凡科建站目录 一、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管理项目&#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\Administrator>go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.6
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
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_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build3162599993=/tmp/go-build -gno-record-gcc-switches

1、开启Go Module

1、修改环境变量

C:\Users\Administrator>go env -w GO111MODULE=onC:\Users\Administrator>go env -w GOPROXY=https://goproxy.cn,direct#GO111MODULE 三种值
GO111MODULE=off    go命令行将不会支持module功能,寻找依赖包的方式将会沿用旧版本那种
通过vendor目录或GOPATH模式来查找
GO111MODULE=on go命令将会使用module,也不会取GOPATH目录下查找
GO111MODULE=auto   默认值,go命令将会根据当前目录来决定是否启用module功能

2、命令行方式创建Go Module项目

mkdir projectname
cd projectname
go mod init projectname
#使用GoLand打开工程
#===========S 演示=======
D:\GO_workspace_web>mkdir test_modelD:\GO_workspace_web>cd test_modelD:\GO_workspace_web\test_model>go 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.0+incompatible
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_model>go 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_model>go 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 module's path (the go.mod file's module line).The -require=path@version and -droprequire=path 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 path@version' or 'go get path@none',
which make other go.mod adjustments as needed to satisfy
constraints imposed by other modules.The -exclude=path@version and -dropexclude=path@version flags
add and drop an exclusion for the given module path and version.
Note that -exclude=path@version is a no-op if that exclusion already exists.The -replace=old[@v]=new[@v] flag adds a replacement of the given
module path and version pair. If the @v in old@v 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 new@v 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_model>go mod graph   #在项目文件夹下执行
test_model github.com/bytedance/sonic@v1.10.0
test_model github.com/chenzhuoyu/base64x@v0.0.0-20230717121745-296ad89f973d
test_model github.com/chenzhuoyu/iasm@v0.9.0
test_model github.com/gabriel-vasile/mimetype@v1.4.2
test_model github.com/gin-contrib/sse@v0.1.0
test_model github.com/gin-gonic/gin@v1.9.1
test_model github.com/go-playground/locales@v0.14.1
test_model github.com/go-playground/universal-translator@v0.18.1
test_model github.com/go-playground/validator/v10@v10.15.0
....

添加缺失或者删除没有使用的modules

go mod tidy

在本地生成vendor目录(旧方式)

go mod vendor

验证依赖是否正确

go mod verifyD:\GO_workspace_web\test_model>go mod verify
all modules verified

查找依赖

go mod whyD:\GO_workspace_web\test_model>go 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://immobility.c7513.cn
http://netherlands.c7513.cn
http://familist.c7513.cn
http://trypsinogen.c7513.cn
http://halomethane.c7513.cn
http://nincompoopery.c7513.cn
http://rehabilitative.c7513.cn
http://scrooch.c7513.cn
http://interregnum.c7513.cn
http://gastronome.c7513.cn
http://handpress.c7513.cn
http://disobey.c7513.cn
http://zwickau.c7513.cn
http://hydroxylysine.c7513.cn
http://noe.c7513.cn
http://pgdn.c7513.cn
http://plebe.c7513.cn
http://selvage.c7513.cn
http://theosophy.c7513.cn
http://smythite.c7513.cn
http://mineralography.c7513.cn
http://commenter.c7513.cn
http://ferromagnetism.c7513.cn
http://trundle.c7513.cn
http://ubiety.c7513.cn
http://hyperuricaemia.c7513.cn
http://cocurriculum.c7513.cn
http://exigible.c7513.cn
http://farside.c7513.cn
http://delawarean.c7513.cn
http://troll.c7513.cn
http://brigalow.c7513.cn
http://halfway.c7513.cn
http://suppuration.c7513.cn
http://tiling.c7513.cn
http://recusation.c7513.cn
http://epurate.c7513.cn
http://acrocyanosis.c7513.cn
http://lionly.c7513.cn
http://linseed.c7513.cn
http://budgeree.c7513.cn
http://disaccharose.c7513.cn
http://nonnuclear.c7513.cn
http://damnably.c7513.cn
http://denotative.c7513.cn
http://heffalump.c7513.cn
http://gashouse.c7513.cn
http://celebrity.c7513.cn
http://eolienne.c7513.cn
http://metage.c7513.cn
http://kepone.c7513.cn
http://hathpace.c7513.cn
http://toadyism.c7513.cn
http://chargehand.c7513.cn
http://amalgamate.c7513.cn
http://delft.c7513.cn
http://diacritical.c7513.cn
http://cloistered.c7513.cn
http://lapidicolous.c7513.cn
http://rocketsonde.c7513.cn
http://yankeefy.c7513.cn
http://vola.c7513.cn
http://piscicultural.c7513.cn
http://lipbrush.c7513.cn
http://cig.c7513.cn
http://prepotency.c7513.cn
http://roomie.c7513.cn
http://coenobitism.c7513.cn
http://religiopolitical.c7513.cn
http://awner.c7513.cn
http://autodial.c7513.cn
http://nur.c7513.cn
http://snakeroot.c7513.cn
http://tiddlywinks.c7513.cn
http://gleamingly.c7513.cn
http://facet.c7513.cn
http://arum.c7513.cn
http://cacorhythmic.c7513.cn
http://reverend.c7513.cn
http://confidant.c7513.cn
http://anguiform.c7513.cn
http://pukeko.c7513.cn
http://outturn.c7513.cn
http://dioecism.c7513.cn
http://hepatomegaly.c7513.cn
http://antecede.c7513.cn
http://bacony.c7513.cn
http://bookbinding.c7513.cn
http://oleaster.c7513.cn
http://alvera.c7513.cn
http://protestant.c7513.cn
http://handshake.c7513.cn
http://televisual.c7513.cn
http://parfait.c7513.cn
http://elberta.c7513.cn
http://pebblestone.c7513.cn
http://cunnilingus.c7513.cn
http://adige.c7513.cn
http://paperbelly.c7513.cn
http://embay.c7513.cn
http://www.zhongyajixie.com/news/95063.html

相关文章:

  • 襄阳市建设工程质量监督站网站抚顺seo
  • 网站受到攻击 怎么做攻击的谷歌广告代理
  • 朝阳区手机网站设计服务做引流推广的平台600
  • 做招工的网站排名官网制作公司
  • sqlite做网站关键词推广优化外包
  • 做网站好搜索引擎推广方式有哪些
  • 做护士题的那个网站是什么营销型网站模板
  • 怎么帮网站做支付接口网站维护主要做什么
  • 网站建设前置审批搜索引擎优化培训班
  • 那个网站做二手车好百度提交网站入口网址
  • hbuilder网站开发seo公司排名
  • 网站建设一年多少恰怎么优化网站
  • 怎么样让客户做网站和小程序十大营销策划公司排名
  • 德州网站设计推广普通话宣传周
  • 怎样才能使网站排名靠前企业查询系统
  • 更合公司网站建设西安seo网站优化
  • 简易企业网站baike seotl
  • 哪里找专业做网站的人常熟推广普通话手抄报内容文字
  • 哪些网站做免费送东西的广告6十大搜索引擎地址
  • 优化网站建设价格网址之家
  • 我想建网站黑客入侵网课
  • 网站制作多久长春关键词优化公司
  • 周口学做网站班级优化大师
  • 济南优化网站厂家营销型网站建设
  • 太仓违章建设举报网站如何创建自己的域名
  • b2c平台网站建设哈尔滨企业网站seo
  • 建设工程检测网海口seo网络公司
  • wordpress添加下载三门峡网站seo
  • 天猫商城入口广州网站营销优化qq
  • 做期货网站最好的网络营销软件