Ubuntu에 golang 패키지 설치

Woody의 기록·2023년 7월 29일
2
post-custom-banner

golang 설치

apt-get으로 패키지 설치

$ apt-get install golang
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  bzip2 g++ g++-11 golang-1.18 golang-1.18-doc golang-1.18-go golang-1.18-src golang-doc golang-go
  golang-src libdpkg-perl libfile-fcntllock-perl libgdbm-compat4 libgdbm6 libglib2.0-0
  libglib2.0-data libicu70 liblocale-gettext-perl libperl5.34 libstdc++-11-dev libxml2 netbase perl
  perl-modules-5.34 pkg-config shared-mime-info xdg-user-dirs xz-utils
Suggested packages:
  bzip2-doc gcc-11-doc bzr | brz ca-certificates git mercurial subversion debian-keyring gnupg
  patch bzr gdbm-l10n libstdc++-11-doc perl-doc libterm-readline-gnu-perl
  | libterm-readline-perl-perl make libtap-harness-archive-perl dpkg-dev
The following NEW packages will be installed:
  bzip2 g++ g++-11 golang golang-1.18 golang-1.18-doc golang-1.18-go golang-1.18-src golang-doc
  golang-go golang-src libdpkg-perl libfile-fcntllock-perl libgdbm-compat4 libgdbm6 libglib2.0-0
  libglib2.0-data libicu70 liblocale-gettext-perl libperl5.34 libstdc++-11-dev libxml2 netbase perl
  perl-modules-5.34 pkg-config shared-mime-info xdg-user-dirs xz-utils
0 upgraded, 29 newly installed, 0 to remove and 0 not upgraded.
Need to get 113 MB of archives.
After this operation, 579 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 liblocale-gettext-perl arm64 1.07-4build3 [16.9 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 perl-modules-5.34 all 5.34.0-3ubuntu1.2 [2977 kB]
...(생략)...

golang 패키지 설치 확인

$ go version
go version go1.18.1 linux/arm64

간단한 golang 코드 작성

$ vim hello.go

"hello.go" 7L, 77B  

import "fmt"

func main() {
    fmt.Println("Hello, Woody!")
}

"hello.go" 7L, 77B    

컴파일 및 실행

$ go build hello.go
$ ./hello
Hello, Woody!

정상적으로 golang이 설치된 것을 확인해 볼 수 있다.

profile
Github - https://www.github.com/woody35545
post-custom-banner

0개의 댓글