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]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
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!

InterfacesandpolymorphisminGoenhancecodereusabilityandmaintainability.1)Defineinterfacesattherightabstractionlevel.2)Useinterfacesfordependencyinjection.3)Profilecodetomanageperformanceimpacts.

Article discusses iterating through maps in Go, focusing on safe practices, modifying entries, and performance considerations for large maps.Main issue: Ensuring safe and efficient map iteration in Go, especially in concurrent environments and with l

The article discusses creating and manipulating maps in Go, including initialization methods and adding/updating elements.

The article discusses differences between arrays and slices in Go, focusing on size, memory allocation, function passing, and usage scenarios. Arrays are fixed-size, stack-allocated, while slices are dynamic, often heap-allocated, and more flexible.

The article discusses creating and initializing slices in Go, including using literals, the make function, and slicing existing arrays or slices. It also covers slice syntax and determining slice length and capacity.

The article explains how to create and initialize arrays in Go, discusses the differences between arrays and slices, and addresses the maximum size limit for arrays. Arrays vs. slices: fixed vs. dynamic, value vs. reference types.

Article discusses syntax and initialization of structs in Go, including field naming rules and struct embedding. Main issue: how to effectively use structs in Go programming.(Characters: 159)

The article explains creating and using pointers in Go, discussing benefits like efficient memory use and safe management practices. Main issue: safe pointer use.


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

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
