Table of Contents
Question content
Solution
Home Backend Development Golang go get and go install on the go.sum file

go get and go install on the go.sum file

Feb 12, 2024 am 09:27 AM
go language

go get 与 go install 在 go.sum 文件上

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
Copy after login

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=
Copy after login

go.mod file is:

module calculator

go 1.20

require github.com/mactsouk/go v0.0.0-20180603081621-6a282087f7bd // indirect
Copy after login

On my $home/go/pkg/mod/github.com/mactsouk/ aod

dr-xr-xr-x  5 user  staff  160 jul  4 18:42 [email protected]
Copy after login
There is nothing on

$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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What libraries are used for floating point number operations in Go? What libraries are used for floating point number operations in Go? Apr 02, 2025 pm 02:06 PM

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

What is the problem with Queue thread in Go's crawler Colly? What is the problem with Queue thread in Go's crawler Colly? Apr 02, 2025 pm 02:09 PM

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. �...

How to solve the user_id type conversion problem when using Redis Stream to implement message queues in Go language? How to solve the user_id type conversion problem when using Redis Stream to implement message queues in Go language? Apr 02, 2025 pm 04:54 PM

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

In Go, why does printing strings with Println and string() functions have different effects? In Go, why does printing strings with Println and string() functions have different effects? Apr 02, 2025 pm 02:03 PM

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? What should I do if the custom structure labels in GoLand are not displayed? Apr 02, 2025 pm 05:09 PM

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...

What is the difference between `var` and `type` keyword definition structure in Go language? What is the difference between `var` and `type` keyword definition structure in Go language? Apr 02, 2025 pm 12:57 PM

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 provided by well-known open source projects? Which libraries in Go are developed by large companies or provided by well-known open source projects? Apr 02, 2025 pm 04:12 PM

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 does not report an error when DSN passes empty? When using sql.Open, why does not report an error when DSN passes empty? Apr 02, 2025 pm 12:54 PM

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

See all articles