go get and go install on the go.sum file
php editor Zimo will introduce to you the use of the "go get" and "go install" commands in the Go language on the go.sum file. In Go language projects, the go.sum file is used to record the packages and their version information that the project depends on, ensuring the stability and consistency of the project during the build and deployment process. By understanding the impact of the "go get" and "go install" commands on the go.sum file, you can better manage and control project dependencies and improve development efficiency and code quality. Let us learn the specific usage of these two commands together!
Question content
I am using go 1.20.3
I just installed this package using go get and go install
go get -v github.com/mactsouk/go/simplegithub go install github.com/mactsouk/go/simplegithub
My go.sum file contains:
github.com/mactsouk/go v0.0.0-20180603081621-6a282087f7bd h1:tqjgx/jaxlj3rnl7ps7xzqlvth8rl/dusa8wpe9w4y0= github.com/mactsouk/go v0.0.0-20180603081621-6a282087f7bd/go.mod h1:trtlpc1xi1zoqdba/cixgds+fcaizdqupmrflet5dbi=
go.mod file is:
module calculator go 1.20 require github.com/mactsouk/go v0.0.0-20180603081621-6a282087f7bd // indirect
On my $home/go/pkg/mod/github.com/mactsouk/ aod
dr-xr-xr-x 5 user staff 160 jul 4 18:42 [email protected]
$home/go/bin/, only two files. Why does go install not copy the binary files of the simplegithub module?
drwxr-xr-x 4 user staff 128 Jun 26 23:37 . drwxr-xr-x 4 user staff 128 Jun 26 23:35 .. -rwxr-xr-x 1 user staff 3410064 Jun 26 23:35 go-outline -rwxr-xr-x 1 user staff 28237216 Jun 26 23:37 gopls
Is there a difference between go get and go install? Why do I have this module file twice on go.sum?
Solution
go get and go install
The go get and go install commands in Go have different purposes:
go get is used to retrieve and download packages and their dependencies from a remote repository. It updates the go.mod and go.sum files with the version of the downloaded package. If the package already exists, go get will update it to the latest version.
go install Compile and install the package in the project's GOPATH or GOBIN. It does not update the go.mod or go.sum files. Instead, it uses the information in these files to determine the correct version of the dependency to use.
In your case, when you run go get, it downloads and installs the package github.com/mactsouk/go/simpleGitHub and its dependencies. This action updates the go.mod and go.sum files with the version of the downloaded package.
When you subsequently run go install on the same package, you do not need to download the package again because it is already present in the local Go module cache. Therefore, go install uses the existing package and its version in the cache and does not modify the go.mod or go.sum files.
The reason you see this module listed twice in the go.sum file is that it contains the module version (v0.0.0-20180603081621-6a282087f7bd) and its corresponding go.mod file, which Contains checksum. This is expected behavior and ensures dependency integrity.
In summary, go get and go install have different purposes. It is normal for modules to be repeated in the go.sum file.
The above is the detailed content of go get and go install on the go.sum file. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Queue threading problem in Go crawler Colly explores the problem of using the Colly crawler library in Go language, developers often encounter problems with threads and request queues. �...

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

The difference between string printing in Go language: The difference in the effect of using Println and string() functions is in Go...

What should I do if the custom structure labels in GoLand are not displayed? When using GoLand for Go language development, many developers will encounter custom structure tags...

Two ways to define structures in Go language: the difference between var and type keywords. When defining structures, Go language often sees two different ways of writing: First...

Which libraries in Go are developed by large companies or well-known open source projects? When programming in Go, developers often encounter some common needs, ...

When using sql.Open, why doesn’t the DSN report an error? In Go language, sql.Open...
