正文
  1. 安装go

  2. 新建项目目录

  3. cmd切换到项目目录

  4. go env -w GOPROXY=https://goproxy.io,direct  更改代理地址

  5. go mod init packagename 项目初始化,packagename 为包名

  6. go mod vendor  安装下载第三方包  


操作例子:


C:\Users\Administrator>d:


D:\>cd goproject


D:\goproject>cd ad


D:\goproject\ad>go mod init ad

go: creating new go.mod: module ad

go: to add module requirements and sums:

        go mod tidy


D:\goproject\ad>go mod vendor

go: finding module for package github.com/gocolly/colly

go: finding module for package github.com/PuerkitoBio/goquery

ad imports

        github.com/PuerkitoBio/goquery: module github.com/PuerkitoBio/goquery: Get "https://proxy.golang.org/github.com/%21puerkito%21bio/goquery/@v/list": dial tcp 216.58.200.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

ad imports

        github.com/gocolly/colly: module github.com/gocolly/colly: Get "https://proxy.golang.org/github.com/gocolly/colly/@v/list": dial tcp 216.58.200.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.


D:\goproject\ad>go env -w GOPROXY=https://goproxy.io,direct


D:\goproject\ad>go mod vendor

go: finding module for package github.com/PuerkitoBio/goquery

go: finding module for package github.com/gocolly/colly

go: downloading github.com/PuerkitoBio/goquery v1.7.1

go: downloading github.com/gocolly/colly v1.2.0

go: found github.com/PuerkitoBio/goquery in github.com/PuerkitoBio/goquery v1.7.1

go: found github.com/gocolly/colly in github.com/gocolly/colly v1.2.0

go: downloading golang.org/x/net v0.0.0-20210614182718-04defd469f4e

go: downloading github.com/andybalholm/cascadia v1.2.0

go: downloading golang.org/x/text v0.3.6

go: finding module for package google.golang.org/appengine/urlfetch

go: finding module for package github.com/gobwas/glob

go: finding module for package github.com/antchfx/xmlquery

go: finding module for package github.com/saintfish/chardet

go: finding module for package github.com/kennygrant/sanitize

go: finding module for package github.com/antchfx/htmlquery

go: finding module for package github.com/temoto/robotstxt

go: downloading github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca

go: downloading github.com/kennygrant/sanitize v1.2.4

go: downloading github.com/gobwas/glob v0.2.3

go: downloading google.golang.org/appengine v1.6.7

go: downloading github.com/antchfx/xmlquery v1.3.7

go: downloading github.com/temoto/robotstxt v1.1.2

go: downloading github.com/antchfx/htmlquery v1.2.4

go: found github.com/antchfx/htmlquery in github.com/antchfx/htmlquery v1.2.4

go: found github.com/antchfx/xmlquery in github.com/antchfx/xmlquery v1.3.7

go: found github.com/gobwas/glob in github.com/gobwas/glob v0.2.3

go: found github.com/kennygrant/sanitize in github.com/kennygrant/sanitize v1.2.4

go: found github.com/saintfish/chardet in github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca

go: found github.com/temoto/robotstxt in github.com/temoto/robotstxt v1.1.2

go: found google.golang.org/appengine/urlfetch in google.golang.org/appengine v1.6.7

go: downloading github.com/antchfx/xpath v1.2.0

go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e

go: downloading github.com/golang/protobuf v1.3.1


D:\goproject\ad>