Mac under Intellij idea go language plugin installation and simple case

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1. Download Address

Wind. Fox
Intellij idea Download (community version is available) https://www.jetbrains.com/idea/download/
Go language Download https://golang.org/dl/
Install http://blog.csdn.net/fenglailea/article/details/26163927 under LINUX

2. Installation

2.1 Intellij Idea installation slightly

2.2 Go Programming Language Installation

Choose Apple OS X here
Go1.7.3.darwin-amd64.pkg (78MB)
Download and install

3. Install the Go language plugin

Intellij idea Menu-"preferences-" Plugins tab


Remember to restart IntelliJ idea

4. Setting Environment variables

Current user

cd ~vim ~/.bash_profile

After opening the file, add the following to the last line:

export GOROOT=/usr/local/goexport GOBIN=$GOROOT/binexport GOARCH=amd64export GOOS=darwinexport GOPATH=/Users/fox/work/go-test1:/Users/fox/work/go-test2

Note that GOPATH the project directory is set according to your own project settings
If there are multiple directories, split with colons
Compile in effect

source ~/.bash_profile

See if it takes effect

echo$GOPATH

If the output information is the same as the one you set, then the configuration is in effect

After the success, here also:
Restart IntelliJ idea

5. New Project





New 3 directories, and 1 examples

binpkgsrcsrc/example/main.go

SRC directory to store Go source code (project source exists in this directory)
PKG Catalog Package Object
Bin directory holds executable objects

Main.go Source:

package mainimport (    "fmt")func main() {    fmt.Println("Hello World!")}

6. Setting up the SDK

menu, File Project Structure

Select the Go Language installation directory



7. Third-party libraries

Execute in the Go project directory:

get gopkg.in/mgo.v2

gopkg.in/mgo.v2is a third-party library
Download speed depends on your speed, if the download is unsuccessful, re-execute the command can be

8. Full configuration effect is as follows


Compiling and running the program

Console print output

9.go Language View Variables

env

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.