Let's add the following code fragment to the helloworld.go file: package main And within the new helloworld folder we create a new Go file named helloworld.go (New -> Go File). In the source folder, we create a new folder named "helloworld". For this example, I have selected "helloworld" as the project name. To create a new Go project we can select File -> New -> Go Project. To test if the goclipse plugin has been configured correctly, we are going to create a simple hello world application. In the Go installation section, we simply select "/usr/local/go"Īfter setting the Go installation location we can quickly go back to the Tools section and double check that the gofmt location has been updated as well (/usr/local/go/bin/gofmt). We also have to specify the path of the Go installation (GOROOT) We simply have to add the following paths:Īdditionally, in the gofmt section, I have unchecked the "Use default location (from Go installation)" as the Go installation path has not been configured yet. Let's add the previously installed Go tools. In my case, the tools section is being opened. We only have to enter the URL in the "Work with:" section.Īfter restarting Eclipse the plugin is available and we can continue configuring the plugin with Window -> Preferences -> Go. Goclipse can be installed using Help -> Install New Software. To install the goclipse plugin we first have to start Eclipse and select "~/go" as our workspace location. cd tar -xzf eclipse-java-neon-3-linux-gtk-x86_64.tar.gz Eclipse Neon can be downloaded from here. For this post, I have decided to use Eclipse Neon as it seems to be more stable than Eclipse Oxygen. rwxr-xr-x 1 user user 8397639 Apr 21 00:20 guru* Install Eclipse Let's check if gocode, guru, and godef were installed correctly. Packages and tools installed with go get are usually installed within the GOPATH location. go get -u go get -u go get /rogpeppe/godef These tools are mainly related to auto-completion and showing package/method descriptions. Now we can install additional tools ( gocode, guru and godef) that will simplify working with Go in the IDE. In case you prefer a different location you have to change the GOPATH environment variable. We will use the default location in this example. GOPATH: This variable points to Go's default location (~/go) for our own projects.GOROOT: This variable points to the location of our Go installation.The most interesting parts at this point in time are: GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build439470921=/tmp/go-build -gno-record-gcc-switches" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" I would also recommend checking the go environment. Let's quickly check if the go command can be found. source /etc/profile Check the Go installation We simply have to add the following line to the end of this file: export PATH=$PATH:/usr/local/go/binĪnd finally, we have to reload /etc/profile to apply the changes in the current session. An easy way to globally add Go to the PATH variable is to edit /etc/profile. cd sudo tar -xzf go1.10.1. -C /usr/local Adjust PATH variableĪdditionally, we should add the location of the extracted Go binary to the PATH variable. Let's extract the downloaded tar.gz file. The default or expected location of Go root is /usr/local on Linux systems. At the time of writing this post, the latest version is go1.10.1. Now we can download Go from the official Go website. sudo apt install git Install Go Download binary package We also need to install git, this is required to be able to install go related packages and tools. sudo add-apt-repository sudo apt sudo apt install oracle-java8-installer Install git One way is to use this PPA to install the JDK. Install Oracle JDK 8įirst, we need to install Oracle JDK 8 as this is required to start the Eclipse IDE. Let's start to install some dependencies. The described process is based on a fresh installation of Ubuntu using a minimal desktop iso image. We are going to install Go and Goclipse (IDE) on an Ubuntu 17.10 / 18.04 environment.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |