Difference between revisions of "Go language"

From OnnoWiki
Jump to navigation Jump to search
(New page: Sumber: http://technosophos.com/2013/12/02/go-1-2-on-ubuntu-12-10.html Installing Go 1.2 on Ubuntu 13.10 Dec 2 2013 Newer Ubuntu distributions ship with various versions of the Go lang...)
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Sumber: http://technosophos.com/2013/12/02/go-1-2-on-ubuntu-12-10.html
 
Sumber: http://technosophos.com/2013/12/02/go-1-2-on-ubuntu-12-10.html
  
 +
Instalasi Go Language versi terbaru
  
 +
==Install godeb==
  
Installing Go 1.2 on Ubuntu 13.10
+
Lakukan
Dec 2 2013
 
  
Newer Ubuntu distributions ship with various versions of the Go language. Ubuntu 13.10, for instance, has an available golang-1.1.2 package. But the most recent version of Go is 1.2.
+
$ sudo apt-get install golang-go
 +
$ sudo apt-get install bzr
 +
$ cd $GOPATH
 +
$ sudo go get launchpad.net/godeb
  
The easiest way to install Go 1.2 on your system is by using the godeb tool. Here's how.
+
Cek
Overview
 
  
godeb is a small tool that grabs the latest version(s) of Go and dynamically constructs a debian package that can be installed on your local Ubuntu/Debian machine.
+
$ $GOPATH/bin/godeb --help
  
There is one caveat to godeb, though: Recent versions of Ubuntu already have the golang package, and the packages that godeb creates will conflict with Ubuntu's package. Here we do a little work to fix that.
+
atau
Installing godeb
 
  
The basics of the godeb project are described on the author's blog. If you need a binary package for godeb, check there.
+
/usr/lib/go/bin/godeb --help
  
Assuming that you have already installed golang via apt-get, it's just as easy to install godeb as a go package:
 
  
$ cd $GOPATH
+
==Uninstall golang==
$ go get launchpad.net/godeb
 
  
You should probably test that godeb works before proceeding:
+
Sekarang uninstall golang untuk menggunakan go yang terbaru melalui godeb
  
$ $GOPATH/bin/godeb --help
+
$ sudo apt-get remove golang-go
 +
$ sudo rm -Rf /usr/share/go/src/pkg
 +
$ sudo rm -Rf /usr/share/go/src/pkg
 +
$ sudo rm -Rf /usr/share/go/src/
 +
$ sudo rm -Rf /usr/share/go/
 +
$ sudo rm -Rf /usr/share/go
 +
$ sudo apt-get autoremove
  
Uninstalling golang
+
==Buat Go Debian Package==
  
Since the Ubuntu golang package will conflict, and since we've already build out godeb tool, we can now uninstall golang:
+
Lakukan
  
$ sudo apt-get remove golang
+
$ sudo su
 +
$ $GOPATH/bin/godeb install
  
This will remove Go from your system, but will leave your $GOPATH alone.
+
atau
Building a New Go Debian Package
 
  
Now we can use godeb to create a new package:
+
sudo su
 +
/usr/lib/go/bin/godeb install
  
$ $GOPATH/bin/godeb install
+
Jika kita tidak melakukan autoremove akan timbul error berikut.
  
This will attempt to fetch the latest Go distribution from golang.org and then build a debian package. If all goes will, it will use dpkg to install it for you.
+
processing https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
OH NO! IT BROKE!
+
package go_1.2-godeb1_amd64.deb ready
 +
Selecting previously unselected package go.
 +
dpkg: regarding go_1.2-godeb1_amd64.deb containing go:
 +
  go conflicts with golang
 +
  golang (version 2:1.1.2-2ubuntu1) is present and installed.
 +
 +
dpkg: error processing go_1.2-godeb1_amd64.deb (--install):
 +
  conflicting packages - not installing go
 +
Errors were encountered while processing:
 +
  go_1.2-godeb1_amd64.deb
 +
error: while installing go package: exit status 1
  
On my systems, part way through godeb's installation I received an error that looks like this:
+
Install ke salahan di atas terjadi, kita dapat secara paksa menginstalasi menggunakan perintah
  
processing https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
+
$ sudo dpkg -i --force-overwrite go_1.2-godeb1_amd64.deb
package go_1.2-godeb1_amd64.deb ready
 
Selecting previously unselected package go.
 
dpkg: regarding go_1.2-godeb1_amd64.deb containing go:
 
go conflicts with golang
 
  golang (version 2:1.1.2-2ubuntu1) is present and installed.
 
  
dpkg: error processing go_1.2-godeb1_amd64.deb (--install):
+
Jika benar maka akan keluar
conflicting packages - not installing go
 
Errors were encountered while processing:
 
go_1.2-godeb1_amd64.deb
 
error: while installing go package: exit status 1
 
  
This error indicates that the dpkg program won't install our newly created Go package because it conflicts with the golang package.
+
processing https://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz
 +
package go_1.2.1-godeb1_amd64.deb ready
 +
Selecting previously unselected package go.
 +
(Reading database ... 295128 files and directories currently installed.)
 +
Unpacking go (from go_1.2.1-godeb1_amd64.deb) ...
 +
Setting up go (1.2.1-godeb1) ...
  
Looking at your filesystem, you should see a package file like go_1.2-godeb1_amd64.deb. If you made it that far then you are actually in good shape. We can easily resolve the error above.
+
==Folder tempat go==
  
All we need to do now is tell dpkg that we want it to install even though there could be a conflict:
+
Kemungkinan besar ada di
  
$ sudo dpkg -i --force-overwrite go_1.2-godeb1_amd64.deb
+
/usr/bin/go
 
 
The force-overwrite flag tells dpkg to cause this package to overwrite any files installed by the Ubuntu golang package.
 
 
 
Once you've run the above command you should be able to run go version to verify that the correct Go version was installed.
 
 
 
Update 2014-04-08: Daniel Hunsaker explained the real solution to the dpkg failure, and provided a a better solution:
 
 
 
    The conflict is because golang is a virtual package. You need to run apt-get autoremove after you uninstall it so that the actual packages get removed as well. Then, no manual dpkg required!
 

Latest revision as of 07:28, 19 April 2014

Sumber: http://technosophos.com/2013/12/02/go-1-2-on-ubuntu-12-10.html

Instalasi Go Language versi terbaru

Install godeb

Lakukan

$ sudo apt-get install golang-go
$ sudo apt-get install bzr
$ cd $GOPATH
$ sudo go get launchpad.net/godeb

Cek

$ $GOPATH/bin/godeb --help

atau

/usr/lib/go/bin/godeb --help


Uninstall golang

Sekarang uninstall golang untuk menggunakan go yang terbaru melalui godeb

$ sudo apt-get remove golang-go
$ sudo rm -Rf /usr/share/go/src/pkg
$ sudo rm -Rf /usr/share/go/src/pkg
$ sudo rm -Rf /usr/share/go/src/
$ sudo rm -Rf /usr/share/go/
$ sudo rm -Rf /usr/share/go
$ sudo apt-get autoremove

Buat Go Debian Package

Lakukan

$ sudo su
$ $GOPATH/bin/godeb install

atau

sudo su
/usr/lib/go/bin/godeb install

Jika kita tidak melakukan autoremove akan timbul error berikut.

processing https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
package go_1.2-godeb1_amd64.deb ready
Selecting previously unselected package go.
dpkg: regarding go_1.2-godeb1_amd64.deb containing go:
 go conflicts with golang
  golang (version 2:1.1.2-2ubuntu1) is present and installed.

dpkg: error processing go_1.2-godeb1_amd64.deb (--install):
 conflicting packages - not installing go
Errors were encountered while processing:
 go_1.2-godeb1_amd64.deb
error: while installing go package: exit status 1

Install ke salahan di atas terjadi, kita dapat secara paksa menginstalasi menggunakan perintah

$ sudo dpkg -i --force-overwrite go_1.2-godeb1_amd64.deb

Jika benar maka akan keluar

processing https://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz
package go_1.2.1-godeb1_amd64.deb ready
Selecting previously unselected package go.
(Reading database ... 295128 files and directories currently installed.)
Unpacking go (from go_1.2.1-godeb1_amd64.deb) ...
Setting up go (1.2.1-godeb1) ...

Folder tempat go

Kemungkinan besar ada di

/usr/bin/go