nats-server系统服务只能使用sc命令注册
golang编译-ldflags -H windowsgui被认为是病毒

golang离线环境依赖包问题

妙音 posted @ 2021年8月21日 17:06 in golang , 1130 阅读
 

问题描述

 
在一个win10虚拟机中安装了go(go1.16.4)的开发环境, 其中有自己的项目,此时正常编译。
    
然后将这个虚拟机放到内网,内网网络受限,不允许访问外网
    
如果新一个依赖包,该怎么办呢?
 
 
 

方法一: 拷贝vendor目录(推荐)

 
1. 在外网环境项目目录,生成vendor
 
go mod vendor
 
2. 将vendor拷贝进内网,放在内网项目目录
 
 
缺点:只能当前项目使用
 
优点:体积小
 
 
类似python的pip download -r requipment.txt,将包下载后放到一个目录
 
 

方法二: 拷贝$GOPATH/pkg/mod目录

 
1. 外在更新全局依赖
 
go mod download
 
2.拷贝进入内网,替换mod目录
 
优点:可以被所有项目公用
 
缺点:有可能会比较大
 
 

方法三: 使用自己的goproxy

 
详细见
https://github.com/goproxyio/goproxy
 
 
 

吐槽

 
不少资料都是介绍GO111MODULE=on/off/auto之类的查找顺序,看得云山雾绕
 
假如GO111MODULE=on,并且在内网,此时无法访问网络,难道它不会找一下当前目录中的vendor?
 
 
Avatar_small
sophia 说:
2023年6月19日 20:02

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to.Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my web site. 천안출장마사지

Avatar_small
sophia 说:
2023年6月25日 11:31

Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us. agencia seo

Avatar_small
sophia 说:
2023年8月21日 10:26

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! large magnum rifle primers

Avatar_small
sophia 说:
2023年8月29日 19:10

I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You. เว็บแทงบอลดีที่สุดUFABET

Avatar_small
Dave 说:
2023年9月07日 13:44

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. bubble shooter game free

Avatar_small
Dave 说:
2023年9月17日 12:27

Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! kitset carport nz

Avatar_small
Dave 说:
2023年10月09日 13:56

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. LIFT DETOX CAPS

Avatar_small
Dave 说:
2023年11月14日 17:47

The clear packaging is like a gallery, showcasing the vivid personalities of each pencil. pencil packing work from home

Avatar_small
Dave 说:
2023年11月16日 16:39

Your articles are inventive. I am looking forward to reading the plethora of articles that you have linked here. Thumbs up! kuliah online kelas karyawan murah

Avatar_small
Dave 说:
2023年11月16日 18:02

Your articles are inventive. I am looking forward to reading the plethora of articles that you have linked here. Thumbs up! temazepam 10mg kopen

Avatar_small
Dave 说:
2023年11月18日 00:42

Your articles are inventive. I am looking forward to reading the plethora of articles that you have linked here. Thumbs up! dental clinic stones corner

Avatar_small
Dave 说:
2023年11月21日 00:44

very interesting keep posting. best lunch cafe in Canggu

Avatar_small
Dave 说:
2023年11月25日 00:18

Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. crimsafe security windows

Avatar_small
tech 说:
2023年12月12日 00:52

I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site. สมัครแทงบอลฟรีUFABET

Avatar_small
Dave 说:
2023年12月20日 17:29

Your articles are inventive. I am looking forward to reading the plethora of articles that you have linked here. Thumbs up! Ladbrokes Slots

Avatar_small
Dave 说:
2023年12月21日 17:32

All your hard work is much appreciated. Nobody can stop to admire you. Lots of appreciation. roket288

Avatar_small
Dave 说:
2023年12月23日 21:05

Your work is truly appreciated round the clock and the globe. It is incredibly a comprehensive and helpful blog. fake id kopen nl

Avatar_small
Dave 说:
2024年1月06日 21:50

Your work is truly appreciated round the clock and the globe. It is incredibly a comprehensive and helpful blog. comprare erba online

Avatar_small
Dave 说:
2024年1月16日 21:40

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. UFABETสมัครแทงบอลคาสิโนออนไลน์

Avatar_small
Dave 说:
2024年1月18日 20:44

i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me. plug and play vape

Avatar_small
Dave 说:
2024年1月19日 18:47

i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me. get 500 likes on instagram

Avatar_small
Dave 说:
2024年1月20日 22:58

i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me. 5000 instagram followers cheap

Avatar_small
Dave 说:
2024年2月08日 20:17

Your work is truly appreciated round the clock and the globe. It is incredibly a comprehensive and helpful blog. comprare erba online

Avatar_small
Dave 说:
2024年2月20日 17:26

Your work is truly appreciated round the clock and the globe. It is incredibly a comprehensive and helpful blog. pets gear


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter