⬆️ ⬇️

Quick start - we program on Go under Windows - the Environment setup

Update (07/22/2013)



Since the initial writing of the article, much has changed. I updated the post a bit so that the outdated instruction did not hang on the network.



Instead of intro



If anyone knows, Go ( www.golang.org ) is a compiled programming language. Like everyone wants to be "better than C." The language development is supported by Google (the creators of the language are Rob Pike, Robert Griesemer and Ken Tompson), but Go is completely open-source, a large number of people not from Google take part in the development. I was interested in the language with its simplicity and unusual approach to OOP and multithreading. I wanted to try. My working OS is Windows and being spoiled by the .Net platform, C # and Visual Studio it was difficult for me to start. Although in reality it turned out to be quite simple, and rather quickly I set up a convenient Environment for myself, consisting essentially of an IDE with the similarity of IntelliSense. I would like to tell you how to do this in 15 minutes.



Go installation



At the time of the last editing of the article, the current version is Go 1.1.1. The distribution can be downloaded at: code.google.com/p/go/downloads/list . We select the distribution kit depending on the bit width of the installed Windows version: x64 - go1.1.1.windows-amd64.msi; x32 - go1.1.1.windows-386.msi. Download, install. Now Go lives in C: \ Go. The installer will set the necessary environment variables.



Workspace



Now you need to create a folder that will be something like a root working directory. Go comes with the “go” utility, which is “all-in-one” - it is used to build projects, install supporters of libraries, run tests, etc. The paradigm Convention over Configuration is used. The only setting that needs to be done is to add the GOPATH environment variable in which to specify the root folder where we will store all the sources of our and third-party projects, compiled libraries and executable files. Create the following folder: C: \ gopath and add the environment variable:

')





You also need to add% GOPATH% \ bin to the environment variable PATH.







IDE installation



Having tried many different text and IDE editors, I chose GoLangIDE ( http://code.google.com/p/golangide/ ). It is very lightweight, i.e. you can simply open file.go and compile it; but at the same time, it fully supports the work on projects under the Convention utility "go". For debug in the Go world, use gdb, this IDE integrates with gdb - you can set breakpoints, view the values ​​of local variables.

In general, download and unpack in C: \. Run C: \ liteide \ bin \ liteide.exe. I advise you to change the semi-Russian language immediately to English: View -> Options, change the language to English, “Apply”, you need to restart the IDE.



Hello world



In the latest version of GoLangIDE, IntelliSense analogue (GoCode) is already built in and nothing needs to be installed. Therefore, we immediately get down to business:

Launch IDE, create a new project (Ctrl + N):







We write fmt, put a dot - we see a drop-down list of functions.







Select a function (press Tab) - you can enter the parameters of the function, press F1 - we see a hint with the signature of the function.







Compiling our Hello World: Ctrl + B

Run in a separate console window: Ctrl + Shift + F5







That's all.



What's next?



There are a lot of good training materials for golang. My collection of links:

tour.golang.org - interactive learning tour

golang.org/doc/effective_go.html - tried to convey the main idea of ​​the language

golangtutorials.blogspot.com/2011/05/table-of-contents.html - collection of great tutorials

miek.nl/files/go - OpenSource Go Book

In search engine queries you need to write golang, and not just go. Successes!

Source: https://habr.com/ru/post/133281/



All Articles