go mod使用及goland配置

本文介绍了Go语言1.12版本后使用`go mod`进行依赖包管理的方式,对比了旧版本的不便,并提供了设置国内源加速的方法,特别是对于Goland用户,详细说明了如何在2019版及以上创建新项目,配置gopath以及goproxy,以优化开发体验。通过示例展示了`go mod`如何自动下载并初始化`go.mod`文件。
摘要由CSDN通过智能技术生成

一.依赖包管理

python有pip方便第三方包管理,java拥有maven管理。

go在旧版本中可以使用go get 命令获取第三方包, 但是偶尔第三方也存在依赖,这样包管理不是很方便

在go 1.12版本后,增加了go mod 来进行依赖包管理, 方便了许多,因此建议使用1.12以上版本(可自行到官网下载)

查看版本

> go version
go version go1.13.9 windows/amd64


>go mod
Go mod provides access to operations on modules.

Note that support for modules is built into all the go commands,
not just 'go mod'. For example, day-to-day adding, removing, upgrading,
and downgrading of dependencies should be done using 'go get'.
See 'go help modules' for an overview of module functionality.

Usage:

        go mod <command> [arguments]

The commands are:

        download    download modules to local cache
        edit        edit go.mod from tools or scripts
        graph       print module requirement graph
        init        initialize new module in current directory
        tidy 
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值