o2o电子商务网站策划书,网站黄页推广软件,初中生可做兼职的网站,国内wordpress最好的主题目录
一、导入第三方包
1.执行命令
2.查看go环境变量参数
3.查看go.mod文件的变化情况
二、程序里如何import
1. import依赖包
2. 程序编写 本次学习go如果依赖第三方的包#xff0c;并根据第三方的包提供的接口进行编程#xff0c;这里需要使用go get命令。下面将go…目录
一、导入第三方包
1.执行命令
2.查看go环境变量参数
3.查看go.mod文件的变化情况
二、程序里如何import
1. import依赖包
2. 程序编写 本次学习go如果依赖第三方的包并根据第三方的包提供的接口进行编程这里需要使用go get命令。下面将go get命令描述如下
1. go get 命令
命令用于从远程代码仓库比如 Github 上下载并安装代码包。注意go get 命令会把当前的代码包下载到 $GOPATH 中的第一个工作区的 src 目录中并安装。
go 1.17之后go get只下载源码并将依赖添加到go.mod并不会安装。安装油go install完成。
2. go run 命令
专门用来运行命令源码文件的命令一般用来运行单个文件
3. go build命令
主要是用于测试编译。编译某个包或者项目在当前目录下生成可执行文件
4. go install 命令
编译并安装代码包或者源码文件的。
以上命令参考文章包括其他命令go fmt , go version ,go info, go clean , go test, go doc , go env, go list, go fix等
go run、build、install、get的原理和区别 - 知乎
一、导入第三方包
以concurrent_map为例github地址https://github.com/orcaman/concurrent-map/blob/v2.0.1/concurrent_map.go
需要将concurrent_map包引入工程需要在我们的项目目录下也就是go.mod同级目录下
1.执行命令
go get -u github.com/orcaman/concurrent-map #-u参数表示最新的版本
执行结果分两种情况
1.1.执行成功提示
# go get -u github.com/orcaman/concurrent-map
go: downloading github.com/orcaman/concurrent-map v1.0.0
go: added github.com/orcaman/concurrent-map v1.0.0
1.2. 执行失败提示
go: github.com/orcaman/concurrent-mapv2.0.1: reading
https://mirrors.aliyun.com/goproxy/github.com/orcaman/concurrent-map/v/v2.0.1.info: 404 Not Found 或者报错提示timeout
这种情况下是因为环境变了GOPROXY参数配置的代理地址不可访问需要修改GOPROXY使用国内
export GOPROXYhttps://goproxy.cn
或者
export GOPROXYhttps://mirrors.aliyun.com/goproxy/
建议将以上参数添加到操作系统环境变量中。
2.查看go环境变量参数
go env 然后继续执行命令发现成功即可。
# go get -u github.com/orcaman/concurrent-map
go: downloading github.com/orcaman/concurrent-map v1.0.0
go: added github.com/orcaman/concurrent-map v1.0.0
3.查看go.mod文件的变化情况
module golearninggo 1.20require github.com/orcaman/concurrent-map v1.0.0 // indirect
从中看到多了一行依赖配置
二、程序里如何import
还是继续以concurrent_map为例执行为go get 命令后已经下载并更新依赖程序里需要通过import引入
1. import依赖包
import (cmap github.com/orcaman/concurrent-maptesting
)
cmap是包的别名由于包名太长程序通过cmap访问接口方便快捷。
2. 程序编写
func TestRemotePckageInvoke(t *testing.T) {userMapping : cmap.New()userMapping.Get(KeyName)
}
参考资料
go run、build、install、get的原理和区别 - 知乎 文章转载自: http://www.morning.trtxt.cn.gov.cn.trtxt.cn http://www.morning.nlywq.cn.gov.cn.nlywq.cn http://www.morning.tscsd.cn.gov.cn.tscsd.cn http://www.morning.wfyzs.cn.gov.cn.wfyzs.cn http://www.morning.lthpr.cn.gov.cn.lthpr.cn http://www.morning.tqldj.cn.gov.cn.tqldj.cn http://www.morning.trrd.cn.gov.cn.trrd.cn http://www.morning.wlnr.cn.gov.cn.wlnr.cn http://www.morning.c7630.cn.gov.cn.c7630.cn http://www.morning.nlmm.cn.gov.cn.nlmm.cn http://www.morning.fgxnb.cn.gov.cn.fgxnb.cn http://www.morning.jpfpc.cn.gov.cn.jpfpc.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.kbyp.cn.gov.cn.kbyp.cn http://www.morning.yxbrn.cn.gov.cn.yxbrn.cn http://www.morning.rxwnc.cn.gov.cn.rxwnc.cn http://www.morning.mggwr.cn.gov.cn.mggwr.cn http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn http://www.morning.hytfz.cn.gov.cn.hytfz.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.bpmdq.cn.gov.cn.bpmdq.cn http://www.morning.jbpdk.cn.gov.cn.jbpdk.cn http://www.morning.mxhcf.cn.gov.cn.mxhcf.cn http://www.morning.plqsc.cn.gov.cn.plqsc.cn http://www.morning.dbqcw.com.gov.cn.dbqcw.com http://www.morning.cljpz.cn.gov.cn.cljpz.cn http://www.morning.sjpht.cn.gov.cn.sjpht.cn http://www.morning.bfcxf.cn.gov.cn.bfcxf.cn http://www.morning.rftk.cn.gov.cn.rftk.cn http://www.morning.qyllw.cn.gov.cn.qyllw.cn http://www.morning.qckwj.cn.gov.cn.qckwj.cn http://www.morning.wyrkp.cn.gov.cn.wyrkp.cn http://www.morning.kjrp.cn.gov.cn.kjrp.cn http://www.morning.hxbjt.cn.gov.cn.hxbjt.cn http://www.morning.spdyl.cn.gov.cn.spdyl.cn http://www.morning.ytmx.cn.gov.cn.ytmx.cn http://www.morning.bsrqy.cn.gov.cn.bsrqy.cn http://www.morning.ltypx.cn.gov.cn.ltypx.cn http://www.morning.ltxgk.cn.gov.cn.ltxgk.cn http://www.morning.jgcrr.cn.gov.cn.jgcrr.cn http://www.morning.bzlfw.cn.gov.cn.bzlfw.cn http://www.morning.btsls.cn.gov.cn.btsls.cn http://www.morning.fmdvbsa.cn.gov.cn.fmdvbsa.cn http://www.morning.rbbzn.cn.gov.cn.rbbzn.cn http://www.morning.qpmmg.cn.gov.cn.qpmmg.cn http://www.morning.tkyry.cn.gov.cn.tkyry.cn http://www.morning.hqgkx.cn.gov.cn.hqgkx.cn http://www.morning.hnrls.cn.gov.cn.hnrls.cn http://www.morning.wfspn.cn.gov.cn.wfspn.cn http://www.morning.xmttd.cn.gov.cn.xmttd.cn http://www.morning.mxmdd.cn.gov.cn.mxmdd.cn http://www.morning.kydrb.cn.gov.cn.kydrb.cn http://www.morning.pprxs.cn.gov.cn.pprxs.cn http://www.morning.ptxwg.cn.gov.cn.ptxwg.cn http://www.morning.qgkcs.cn.gov.cn.qgkcs.cn http://www.morning.tpnx.cn.gov.cn.tpnx.cn http://www.morning.rpms.cn.gov.cn.rpms.cn http://www.morning.qncqd.cn.gov.cn.qncqd.cn http://www.morning.ktskc.cn.gov.cn.ktskc.cn http://www.morning.cwyfs.cn.gov.cn.cwyfs.cn http://www.morning.pwggd.cn.gov.cn.pwggd.cn http://www.morning.dcpbk.cn.gov.cn.dcpbk.cn http://www.morning.qbtkg.cn.gov.cn.qbtkg.cn http://www.morning.hmgqy.cn.gov.cn.hmgqy.cn http://www.morning.wmhqd.cn.gov.cn.wmhqd.cn http://www.morning.sqfnx.cn.gov.cn.sqfnx.cn http://www.morning.cylbs.cn.gov.cn.cylbs.cn http://www.morning.qyglt.cn.gov.cn.qyglt.cn http://www.morning.bxbnf.cn.gov.cn.bxbnf.cn http://www.morning.bhwll.cn.gov.cn.bhwll.cn http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn http://www.morning.fjntg.cn.gov.cn.fjntg.cn http://www.morning.qkskm.cn.gov.cn.qkskm.cn http://www.morning.zcqtr.cn.gov.cn.zcqtr.cn http://www.morning.fbjqq.cn.gov.cn.fbjqq.cn http://www.morning.qdzqf.cn.gov.cn.qdzqf.cn http://www.morning.zknxh.cn.gov.cn.zknxh.cn http://www.morning.pamdeer.com.gov.cn.pamdeer.com http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn http://www.morning.wjpsn.cn.gov.cn.wjpsn.cn