Use Sublime text 3 to create a small but powerful go language development IDE

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

Use Sublime text 3 to create a small but powerful go language development IDE

Recently in the Learning Go language, online search for the Go language IDE, found that the go language currently does not have a professional IDE, are some of the various plug-ins to achieve, due to the features of go:

    • The development process needs to be setGOPATH
    • Use third-party packagesgo get
    • Use it when you run it.go run
    • Packaged to usego install
    • When you cross-compile, you also configure GOARCH GOOSgo build

Tried a lot of friends to share the tools are very bad use, a trial of JetBrains Goland Early build version, found a lot of bugs, no cross-compiling, cannot go get , and can not meet the development, packaging, distribution needs, However, Goland code hints are particularly good, I hope that the official version of the future can do better.

Build your own IDE for Go language development

All right, crap, don't talk. To start building a powerful go language development IDE, to what extent, their own experience it:

    • Automatic configuration supportGOPATH
    • Supports a simplego run
    • Supportgo get
    • Supportgo install
    • And of course, "cross-compilation" is supported.
    • And it also supports go testgo clean

Download and install sublime text 3

The sublime text is a small text editing tool that supports Windows, Linux, MacOS, official download address click Sublime Text.
Download it and install it yourself, there should be no problem here.

Install the package control

The package control is a sublime-text plug-in management tool, and because of the sublime text comes with a Python environment, it can be automatically installed using the Python script as follows ( Suggest to go to the official website to find the script, lest the script update, cannot install):

For ease of viewing, I ; added a newline character after the semicolon in the script, but it doesn't affect the use.

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; 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 validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

Official installation Address package control installation, you will see the above script when you go in.

Of course, the package control also has manual installation methods:

    • Click Preferences > Browse Packages ... Menu
    • Open the installed packages/folder
    • Download Package Control.sublime-package
      and copy the downloaded files to the installed packages/directory.
    • Restart Sublime Text

The automatic installation must also be restarted to take effect.

Install the official Golang build package from the Go language

    • Click Preferences > Package Control menu (Mac shortcut shift + command + p )
    • Enter Select Package Control:install in the input box that pops up install
    • Then enter Golang build Select Golang Build Installation

After installation click Preferences Preferences > package Setting > golang Config > setting-user set a Some parameters

{    "PATH": "/usr/local/go/bin",    // 这里改成你自己的GOPATH    "GOPATH": "$HOME/golang/workspace"}

Okay, now we can try.

    • Create a directory under Workspace src :
      mkdir -p $HOME/golang/workspace/src
    • Create a Go filehello.go
    • Write the following:
package mainimport (    "github.com/iTaa/testGoGet")func main() {    testGoGet.TestGoGet()}

Go get test

    • -click Preferences > Package Control menu (Mac shortcut shift + command + p )
    • Enter in the popup box go get and click Go:get

      Go get test
    • Output go get test success! Prove that you can use go get.

Go get test

Get run, go install, go build, go clean etc test

    • Click Toos > Build with (Mac shortcut SHIFT + COMMAND + b)

Go Build
    • See the following command, click to



      Go Build

Installing Gosublime

Gosublime is an interactive go build tool that is also handy to use with Golang build.

    • Click Preferences > Package Control menu (Mac shortcut shift + command + p )
    • Enter Select Package Control:install in the input box that pops up install
    • Then enter GoSublime Select Gosublime to install

Using Gosublime

    • Configure the Gosublime automatic settings Gopath

Gosublime
    • Set "use_gs_gopath": true , default is False

Use_gs_gopath
    • It's done.

The way of use is also:

    • Click Toos > Build with (Mac shortcut SHIFT + COMMAND + b)
    • Select Gosublime an interactive input will appear

Gosublime

Here you can enter the commands you want to use, go get, go install, go build, go clean, all can.

The article wrote a morning, more content, there may be some places did not describe clearly, if there are questions please leave a message.

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.