借助码云快速安装 golang.org/x/lint/golint 和 golang.org/x/tools/ 等依赖

本文详细介绍如何使用VSCode搭建GO的基本开发环境,包括安装必要的工具集,如guru、gorename、lint、golint等,并提供了解决golang.org被墙导致的工具无法直接获取的问题的方法,以及通过码云加速下载的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GO基本开发环境搭建

  • 入门时使用VSCode是比较方便的, VSCode 会推荐我们安装如下工具

  • tools 工具集

    • guru golang.org/x/tools/cmd/guru
    • gorename golang.org/x/tools/cmd/gorename
  • lint golang.org/x/lint

    • golint golang.org/x/lint/golint
  • go-outline github.com/ramya-rao-a/go-outline

  • go-symbols github.com/acroca/go-symbols

  • goreturns github.com/sqs/goreturns

安装完后就会在GOPATH中能找到这些工具对应的命令了, 由于 golang.org 被墙

  • 所以 只有这几个工具不能直接 go get :
    • guru gorename imports(goreturns要用到) lint golint

github.com/golang/tool… 是 tools 的Github地址, github.com/golang/lint 是 lint 和 golint 的Github地址,

mkdir -p src/golang.org/x/tools
mkdir -p src/golang.org/x/lint
将 https://github.com/golang/tools clone所有内容 放到 src/golang.org/x/tools 下
将 https://github.com/golang/lint clone所有内容 放到 src/golang.org/x/lint 下
此时再执行 go get 那五个工具即可全部安装成功
复制代码

利用码云加速下载

问题又来了, Github 由于飘忽不定的被墙, 网速特别慢, 就可以利用码云来加速下载

lint https://gitee.com/gin9/golang-lint.git
tools https://gitee.com/gin9/golang-tools.git
复制代码

步骤很简单, 就是利用码云从Github的代码迁移功能, 如果要更新如上工具, 只要在码云同步下Github的代码, 然后自己手动更新即可 自己新建一个同步的项目

转载于:https://juejin.im/post/5cb54db6f265da035632278a

在linux可以使用“make geth”,那在window下输入什么命令可以达到相应目的,以下是Makefile文件中的内容:“# This Makefile is meant to be used by people that do not usually work # with Go source code. If you know what GOPATH is then you probably # don't need to bother with make. .PHONY: geth all test lint fmt clean devtools help GOBIN = ./build/bin GO ?= latest GORUN = go run #? geth: Build geth. geth: $(GORUN) build/ci.go install ./cmd/geth @echo "Done building." @echo "Run \"$(GOBIN)/geth\" to launch geth." #? all: Build all packages and executables. all: $(GORUN) build/ci.go install #? test: Run the tests. test: all $(GORUN) build/ci.go test #? lint: Run certain pre-selected linters. lint: ## Run linters. $(GORUN) build/ci.go lint #? fmt: Ensure consistent code formatting. fmt: gofmt -s -w $(shell find . -name "*.go") #? clean: Clean go cache, built executables, and the auto generated folder. clean: go clean -cache rm -fr build/_workspace/pkg/ $(GOBIN)/* # The devtools target installs tools required for 'go generate'. # You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'. #? devtools: Install recommended developer tools. devtools: env GOBIN= go install golang.org/x/tools/cmd/stringer@latest env GOBIN= go install github.com/fjl/gencodec@latest env GOBIN= go install google.golang.org/protobuf/cmd/protoc-gen-go@latest env GOBIN= go install ./cmd/abigen @type "solc" 2> /dev/null || echo 'Please install solc' @type "protoc" 2> /dev/null || echo 'Please install protoc' #? help: Get more info on make commands. help: Makefile @echo '' @echo 'Usage:' @echo ' make [target]' @echo '' @echo 'Targets:' @sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'”
最新发布
03-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值