Go Development Environment Configuration

Source: Internet
Author: User
Tags sublime text
Go_dev_toolsublime text2

Download

Install package Control

After opening, press Ctrl + ~ Open the command line, or in view-> show console, copy the following code and execute

import urllib2,os,hashlib; h = ‘7183a2d3e96f11eeadd761d777e62404‘ + ‘e330c659d4bb41d3bdf022e94cab3cd0‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( ‘http://sublime.wbond.net/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), ‘wb‘ ).write(by) if dh == h else None; print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h) if dh != h else ‘Please restart Sublime Text to finish installation‘)
Install gosublime and configure
{    "env": {        "GOPATH": "~/workspace:$GS_GOPATH"    },    "autocomplete_builtins": true,    "autocomplete_suggest_imports": true}
Install golint

Golint is used to detect Syntax problems

go get github.com/golang/lint
golint filename

Some standard errors will be prompted. You can deploy them in gosublime or fswatch.

Install goimporter
go get code.google.com/p/go.tools/cmd/goimports

After compilation, set an ln-S to the $ Gobin directory (or copy the past), and add a line to the user-setting of gosublime.

"fmt_cmd": ["goimports"]

Note: ln-S requires an absolute path.

Fswatch hot Compilation
go get github.com/codeskyblue/fswatch

Connect to/usr/bin/fswatch after build
Execute fswatch in the desired directory to generate. fswatch. JSON
Then write the command to be executed in comman. refer to the following:

{    "paths": [        "."    ],    "depth": 2,    "exclude": [],    "include": [        "\\.(go|py|php|java|cpp|h|rb)$"    ],    "command": [        "bash",        "-c",        "pgrep server | xargs kill && golint ./ && go build server.go && ./server"    ],    "env": {        "POWERD_BY": "github.com/codeskyblue/fswatch"    },    "kill-signal": "KILL"}

Note: faswtch does not automatically kill the running process. Therefore, you need to manually kill the process and try again.

Merge golint into the monitoring directory to facilitate content modification.

Supervisor
[program:vehiclestat]command=~/workspace/vehicleStat/src/vehicleStat/vehicleStatautostart = trueautorestart = truestartsecs = 5user = rootredirect_stderr = truestdout_logfile = /var/log/supervisord/vehicleStat.log
Others

Set the current directory to $ gopath

alias gopath=‘export GOPATH=`pwd` && echo $GOPATH‘
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.