Java Programmer Go Language learning environment building

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

Objective

For a variety of reasons, to understand the relevant grammar of the go language, development tools, and some open source framework, by the way on their own programming path to find a development language, in a short time to complete my development goals, of course, in the process of looking for programming language, PHP is not in the scope of exploration, in addition to say, Limited to personal economic conditions, only in the difficult Windows environment to explore, so the following are some of the Windows-based experience of the talk, here, I said "experience", not to say is experience oh ... Indicates that I am also a rookie, improper place, also please treatise

Download and install Go tools

This go tools is equivalent to Java's JDK.
Download directory https://golang.org/dl/, find the package you want to download, unzip it to any directory you want to unzip, the directory I unzipped here is D:\Tools\go

Configuring Environment variables

As a practical programmer, words always have to say less, after all, no picture no truth, the following we want to configure is Goroot, Gopath. Goroot is the directory of the previous decompression, Gopath is the location of our code, equivalent to the working space

Verifying the Environment

Open the console, enter Go version, and then enter, the console will print the current Go language version, here is not bright map, too many, easy to design Tucson broken

Hello World

    • Create a new directory under the%gopath% directory Src/github.com/strawbird/hello of course this directory with you happy, the reason is so built (cheap), I also have a reason, because after we compile, the%gopath% directory will generate a bin directory , inside is the executable file, hello this directory is a directory of the project, and later new projects to distinguish Github.com/strawbird I use it as a namespace, equivalent to the Java package
    • Create a new file in the Hello directory called Hello.go, enter the following code in the Hello.go
 package main    import "fmt"    func main() {        fmt.Printf("hello, world\n")    }
    • Execute the following command to compile the hello.go, and then generate the Hello.exe file in the bin directory in the Gopath directory after execution

Go Install Github.com/strawbird/hello

    • You can see the word Hello World on the console by executing the following command

%gopath%/bin/hello

Idea installs the Go language plugin

Choose Go to install the following, after the installation of the SDK configuration, we do not configure here is OK, when we import the project, idea will prompt us to do, here is not much to say

Import (Open) Project

It looks like this when it's open.

Run the project

Reference documents

"1" http://springfox.github.io/springfox/

This article is based on attribution-NonCommercial use-shared 4.0 license Agreement published, Welcome to reprint, use, republish, but be sure to keep the article named Rice Straw bird person (including this subscription number QR code)

Related Article

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.