Golang command: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
</pre>
</pre>
Get downloads the packages named by the import paths, along with their dependencies. It then installs the named packages, like 'go install'.
Get downloads the packages named by the import paths, along with their dependencies. It then installs the named packages, like 'go install'.
Gitlab private repo 에 저장된 go package 를 go get 을 이요앻서 내려받을 때에는 권한 문제가 발생한다. 이럴 경우, 다음과 같이 git 설정을 변경하면 된다.
출처: https://stackoverflow.com/questions/29707689/how-to-use-go-with-a-private-gitlab-repo
<pre>
$ git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"
</pre>
go mod 에 있는 모든 패키지들을 한꺼번에 업그레이드 하기 위해서는 다음을 입력하면 된다.
<pre>
$ go get -u all
</pre>


=== -d ===
=== -d ===

Latest revision as of 15:18, 2 September 2021

Overview

Golang 명령어 내용 정리

get

usage: go get [-d] [-f] [-t] [-u] [-v] [-fix] [-insecure] [build flags] [packages]

Get downloads the packages named by the import paths, along with their dependencies. It then installs the named packages, like 'go install'.

Gitlab private repo 에 저장된 go package 를 go get 을 이요앻서 내려받을 때에는 권한 문제가 발생한다. 이럴 경우, 다음과 같이 git 설정을 변경하면 된다. 출처: https://stackoverflow.com/questions/29707689/how-to-use-go-with-a-private-gitlab-repo

$ git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"

go mod 에 있는 모든 패키지들을 한꺼번에 업그레이드 하기 위해서는 다음을 입력하면 된다.

$ go get -u all

-d

Package 다운로드 만을 한다. 패키지 설치는 하지 않는다. The -d flag instructs get to stop after downloading the packages; that is, it instructs get not to install the packages.

-f

The -f flag, valid only when -u is set, forces get -u not to verify that each package has been checked out from the source control repository implied by its import path.This can be useful if the source is a local fork of the original.

-u

The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.

-v

Verbose. 상세 작업 진행 내역을 보여준다. The -v flag enables verbose progress and debug output.

mod

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        add missing and remove unused modules
	vendor      make vendored copy of dependencies
	verify      verify dependencies have expected content
	why         explain why packages or modules are needed

Go mod provides access to operations on modules.