How to use GoLand ide go mod to build a project

Time:2021-4-3

No matter what programming language you learn, there are four steps you will go through at the beginning

  • Development tools installation
  • IDE installation
  • Set dependency / package image
  • Project building tools, managing dependencies / packages

1、 Installation of golang development tools

https://golang.org/ Official website (need respective means)
https://github.com/golang/go GitHub address
http://docscn.studygolang.com/ Golang Chinese website

2、 GoLand ide installation

https://www.jetbrains.com/zh-cn/go/

3、 Set dependency / package image

Goland新建项目

Common image address:

Alibaba cloud:https://mirrors.aliyun.com/goproxy
Microsoft:https://goproxy.io
Qi niuyun:https://goproxy.cn
 GoCenter: https://gocenter.io

4、 Project building tools, managing dependencies / packages

Reference article

An introduction to the relationship among root, gopath and go modules
https://www.jb51.net/article/197551.htm

1. In go.mod Chinese Editor

在这里插入图片描述

go.mod You can write the following keywords:

  • module

Define module path

  • go

Define go language version

  • require

Specify the dependent suite. The default is the latest version. You can specify the version number

  • exclude

Exclude the kit and its version

  • replace

Use a different KIT version and replace the original kit version annotation
//Single line annotation
/*Multiline annotation*/
Indirect represents the dependency package that is indirectly imported

2. Command line go get address

go get

As long as it’s opengo modulesFunction,go getIt’s not going to be like beforeGOPATH/srcThe package file will be placed in theGOPATH/pkg/modInside, andgo.modI will write the introduction, so I don’t need to use itgo mod downloaThe D command is out.

summary

Here is the article about how to use Golan ide go mod to build a project. For more information about Golan ide go mod, please search previous articles of developer or continue to browse the following articles. I hope you can support developer more in the future!