1. Toad Notes Go language--Getting Started

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

1. Toad Notes Go language--Getting Started

Brief introduction

The go language is a simple, efficient, secure, and concurrent language. Simple to not even need to have a symbol table for lexical analysis. It can be compiled quickly, and it is common for the entire project to compile in seconds or less. It has garbage collection, so it is safe from the memory point of view. It does a static type check and does not allow the coercion of type conversions, and is therefore safe for the type. At the same time, the language also built a powerful concurrency implementation mechanism.

The author of the Go language adheres to a single guiding principle when designing this language: simplicity and clarity.

The variables are declared as follows:

var sum int//Simple declaration

var total int = 42//Declaration and initialization

The types in these declarations are followed by the variable names.

If a variable is initialized, the compiler can usually infer its type, so the programmer does not have to explicitly knock it out:

var label = "Name"

Go Language Eclipse development environment

The Go development environment is as follows:

Http://www.golangtc.com/download (Outside the wall: https://golang.org/dl/)

After the installation is complete, the environment variable Path is added to the bin directory under the Go installation directory C:\Go\bin\, and the environment variable goroot is added, and the value is the Go install root directory C:\Go\

Enter the go command at the command line

Use Go env to view environment variables

Setting environment variables:gopath

Working directory.

IDE development environment

Adopt Sublimetext 3 (hereinafter referred to AS Sublime ) +gosublime+gocode Combination

Sublime Text 3

L Download Address: HTTP://WWW.SUBLIMETEXT.COM/3

Double-click Install.

L installation Package Control Package Management Tools
Click View->show Console, and then paste to execute the following code

Importurllib.request,os,hashlib; h = ' 2915d1851351e5ee549c20394736b442 ' + ' 8bc59f460fa1548d1514676163dafc88 '; PF = ' package control.sublime-package '; ipp= Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); by =urllib.request.urlopen (' http://packagecontrol.io/' + pf.replace (', '%20 '). read (); DH = hashlib.sha256 (by). Hexdigest (); Print (' Error validatingdownload (got%s instead of%s), please try manual install '% (DH, h)) if DH!=h else open (Os.path. Join (IPP, PF), ' WB '). Write (by)

if it is Sublime2 is the following:

importurllib2,os,hashlib; h = ' 2915d1851351e5ee549c20394736b442 ' + ' 8bc59f460fa1548d1514676163dafc88 '; PF = ' package control.sublime-package '; ipp= Sublime.installed_packages_path (); Os.makedirs (IPP) if Notos.path.exists (IPP) else None; Urllib2.install_opener (Urllib2.build_opener (urllib2. Proxyhandler ())); by = Urllib2.urlopen (' http://packagecontrol.io/' +pf.replace (', '%20 '). read (); DH = hashlib.sha256 (by). Hexdigest (); Open (Os.path.join (IPP, PF), ' WB '). Write (by) if DH = = h else None; Print (' errorvalidating download (got%s instead of%s), please try manual install '% (dh,h) if DH! = H Else ' please Restar T Sublime Text to finish installation ')

and then restart Sublime can be found in the menu bar perfrences more than one of the following columns, indicating Package Control the installation is successful .

Https://packagecontrol.io/installation#st2 specific installation.

L installation Gosublime Plugins , Open Packagecontroll input Install Package " (i.e. "Packagecontrol:install Package" ), and then enter Gosublime , press OK to start the installation.

L installation of the same step Golangbuild

L then install Gocode Code Automatic Hints
Open Windows the command line prompt program, cmd Run the following code

Go get-u github.com/nsf/gocode

Go Install Github.com/nsf/gocode

If you have an error message, install the Git Client

L Set Go Smart tips for non-standard libraries

Open Perferences->settings-default , copy all the contents, and paste it into Settings-user (Ensure that your changes are not reset by the plugin update, which is frequently updated).

Write the first program

in the Gopath folder's src files are created Hello.go file, enter as follows:

Package Main

Import (

"FMT"

)

Func Main () {

Fmt. Println ("helloworld!")

}

Then run ctrl+b to open the sublime command line

At the prompt, enter go run hello.go

Ctrl+b Open the Sublime command line and enter go build hello.go at the prompt

Compiled into a binary file.

If you need to enter again, Tools->build system->gosublime, and then enter Ctrl+b.

Go language Learning Materials

1.go Guide: Official website link:https://go-tour-zh.appspot.com/welcome/1, if unable to open please use domestic link:http://tour.studygolang.com/

2. "The way to go", if you feel the difficulty of reading English, on GitHub no smell Daniel has done a Chinese translation:Https://github.com/Unknwon/the-way-to-go_ZH_CN

3. The third edition of Go Learning notes, rain Marks, the ebook on GitHub open Source:Https://github.com/qyuhen/book

4. "Go Web Programming" is an ebook written by Matchmaker (Beego's author), the GitHub Chinese Catalog link:https://github.com/astaxie/build-web-application-with-golang/ Blob/master/zh/preface.md

5. "Go Programming Basics" Video tutorial, this tutorial is a no-smell Daniel, github video link:https://github.com/Unknwon/go-fundamental-programming

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.