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

重庆做网站个人专业做网站公司哪家好

重庆做网站个人,专业做网站公司哪家好,青岛关键词排名提升,wordpress客户端配置注意事项 所谓的远程仓库指的是github#xff0c;个人首次使用go mod在其他云仓库上尝试#xff0c;并未成功#xff0c;这浪费了我近2小时的时间#xff1b; 如果你是初次尝试#xff0c;那么除了github的地址换一下之外#xff0c;其他的都按照示例操作#xff0c;比如… 注意事项 所谓的远程仓库指的是github个人首次使用go mod在其他云仓库上尝试并未成功这浪费了我近2小时的时间 如果你是初次尝试那么除了github的地址换一下之外其他的都按照示例操作比如目录的创建这也是我把我的操作步骤一个不拉地贴出来的原因你只须按着做必定成功 如果你没有引用github上的go模块也不打算分享代码到github那么go mod对你没有任何作用使用GOPATH即可。   在github上创建一个仓库 https://github.com/2haodb/gomng.git 把项目复制到本地并提交一份代码上去 cd git clone https://github.com/2haodb/gomng.git cd gomng/ git remote add mng https://github.com/2haodb/gomng.git cp -r /opt/dev/test/src/mod_test/ . git add . git commit -m 1.0.1 git push -u mng master   代码内容 别人向你提到使用GO展示一个东西时一定要用到GO的一些特性尤其是面试官让你用GO写一段代码的时侯 rootblack:~/gomng/mod_test/main# cd .. rootblack:~/gomng/mod_test# ls main pkg1 rootblack:~/gomng/mod_test# cd pkg1/ rootblack:~/gomng/mod_test/pkg1# cat test.go package pkg1 import(fmttime )func Test(){c : make(chan struct{})go func(){fmt.Println(我要出去看看园子里的花还活着吗)time.Sleep(7*time.Second)c - struct{}{}}()- cfmt.Println(这花被别人拿走了再也看不到它了) }   rootblack:~/gomng/mod_test/main# cat main.go package main import(github.com/2haodb/gomng/mod_test/pkg1 )func main(){pkg1.Test() }   执行go mod # echo $GOPATH/opt/code/gopath:/opt/dev/test export GO111MODULEon cd ~/gomng/mod_test/pkg1/ rm -rf go.mod go mod init github.com/2haodb/gomng/mod_test/pkg1 rootblack:~/gomng/mod_test/main# go mod init github.com/2haodb/gomng/mod_test/main go: creating new go.mod: module github.com/2haodb/gomng/mod_test/main rootblack:~/gomng/mod_test/main# ll total 16 drwxr-xr-x 2 root root 4096 9月 12 18:03 ./ drwxr-xr-x 4 root root 4096 9月 12 17:24 ../ -rw------- 1 root root 54 9月 12 18:03 go.mod -rw-r--r-- 1 root root 99 9月 12 17:31 main.go rootblack:~/gomng/mod_test/main# cat go.mod module github.com/2haodb/gomng/mod_test/maingo 1.12   重点说明-版本号 在github有类似下面的话就在页面上绿色的按钮点击下载的位置的下面一行其中这个4166d71就是go mod需要的版本号 Latest commit4166d7121 minutes ago   那么对应的require部分可以这么写 module github.com/2haodb/gomng/mod_test/mainrequire github.com/2haodb/gomng/mod_test/pkg1 4166d71 go 1.12   在运行程序之后会自动转化为下面的v版本 rootblack:~/gomng/mod_test/main# cat go.mod module github.com/2haodb/gomng/mod_test/main require github.com/2haodb/gomng/mod_test/pkg1 v0.0.0-20190912093654-4166d71402a6 go 1.12   运行示例 rootblack:~/gomng/mod_test/main# go run main.go go: finding github.com/2haodb/gomng/mod_test/pkg1 4166d71 我要出去看看园子里的花还活着吗 这花被别人拿走了再也看不到它了 rootblack:~/gomng/mod_test/main# go run main.go 我要出去看看园子里的花还活着吗 这花被别人拿走了再也看不到它了 可以看到首次运行的结果与第二次不一样这是因为首次运行时go把依赖的模块下载下来了 mod自动下载代码位置 go mod方式运行代码时自动将依赖的模块下载到$GOPATH/pkg/mod目录下后续运行直接引用mod下的模块同时不会再去$GOPATH/src目录下找了。 rootblack:~# echo $GOPATH /opt/code/gopath:/opt/dev/test rootblack:~# ll /opt/code/gopath/pkg/mod/github.com/2haodb/gomng/mod_test total 12 drwxr-xr-x 3 root root 4096 9月 12 17:41 ./ drwxr-xr-x 3 root root 4096 9月 12 17:41 ../ dr-x------ 2 root root 4096 9月 12 17:41 pkg1v0.0.0-20190912093654-4166d71402a6/   重新演示一下上面的流程-任意位置 rootblack:/tmp# mkdir ccc rootblack:/tmp# cd ccc/ rootblack:/tmp/ccc# vim main.go rootblack:/tmp/ccc# go mod init github.com/2haodb/gomng/mod_test/main go: creating new go.mod: module github.com/2haodb/gomng/mod_test/main rootblack:/tmp/ccc# vim go.mod rootblack:/tmp/ccc# go run main.go go: finding github.com/2haodb/gomng/mod_test/pkg1 4166d71 我要出去看看园子里的花还活着吗 这花被别人拿走了再也看不到它了 main.go与go.mod的内容与之前相同不同的是主程序的位置变了 但这没有关系这正是go mod的意义所在你的项目代码可以在任意位置放置只须正确引用github的代码同时也无须关心依赖包的问题了因为运行程序时, go自动下载依赖包到本地$GOPATH/pkg/mod目录。 关闭go mod export GO111MODULEoff 关闭后GOPATH生效   转载于:https://www.cnblogs.com/perfei/p/11514497.html
http://www.zqtcl.cn/news/527902/

相关文章:

  • 网站域名注册商查询徐州集团网站建设报价
  • 句容网站设计公司做网站充值犯法吗
  • 网站建设所用系统网站备案目的
  • 苏州做网站优化公司哪家好网站的大小
  • 四川省住房和城乡建设厅官方网站网站建设图标图片
  • 做影视网站侵权吗评论凡科网站建设怎么样
  • 建设个人网站流程建设游戏网站需要哪些设备
  • 四字母net做网站怎么样河南做网站优化
  • 怎样做网站快照网站当前位置怎么做
  • 网站模板移植现在c 做网站用什么框架
  • 国内专业的室内设计网站盐城网站开发代理商
  • 外贸网站建设 评价wordpress 函数调用
  • 广告支持模式的网站二级域名做网站域名
  • 空间 两个网站购物网站建设图标大全
  • 17.zwd一起做网站广州网站制作费用
  • 如何选择网站建设公司网站开发公司vue框架
  • 网站建设设计外包公司360个人网站建设
  • 什么网站专做店铺公司注销的网站备案
  • 不属于c2c网站的是带货视频怎么制作教程
  • 3g小说网站怎么自己用手机做网站
  • 广告行业包括网站建设吗关键词优化排名易下拉系统
  • 皖icp网站建设地方汽车网站模板购买
  • 在哪个网站做科目一考试题域名多少钱一年
  • 红孩子母婴网站开发背景建网站可行性分析
  • 北京 网站设计飞沐商城网站技术方案
  • 大连网站建设价格低怎么加入网站做微商城
  • 惠山网页制作北京优化推广
  • 武威做网站网站流量分析怎么做
  • 用动态和静态设计一个网站cname wordpress
  • php装修门户网站源码PHP是做网站最好的