go-plus

module
v3.0.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2014 License: Apache-2.0

README

go-plus – Improved Go Experience In Atom

OSX Build Status Windows Build status

Installing

  1. Install autocomplete-plus: apm install autocomplete-plus or open Atom and go to Preferences > Packages, search for autocomplete-plus, and install it
  2. Install go-plus: apm install go-plus or open Atom and go to Preferences > Packages, search for go-plus, and install it

Overview

This package adds extra Atom functionality for the go language:

  • Autocomplete using gocode (you must have the autocomplete-plus package installed for this to work)
  • Formatting source using gofmt
  • Formatting and managing imports using goimports, goreturns, or gofmt
  • Code quality inspection using go vet
  • Linting using golint
  • Syntax checking using go build and go test
  • Display of test coverage using go test -coverprofile

Example

A screenshot of go-plus in action

Platforms

The package is currently known to work on OS X, Windows (7+) and Ubuntu. CI jobs exist for OS X and Windows; Ubuntu CI is still in-progress.

Defaults

By default, the package has the following preferences enabled:

  • Environment Overrides Configuration: allow environment variables (e.g. $GOPATH or %GOPATH%) to override configured values (e.g. Gopath)
  • Format On Save: run gofmt or goimports on save
  • Format With Go Imports: use goimports instead of gofmt
  • Get Missing Tools: run go get -u on startup for all missing tools
  • Lint On Save: run golint on save
  • Run Coverage On Save: run go test -coverprofile & cover on save, and display coverage in the editor
  • Show Panel: show the message panel at the bottom of the screen if any errors or warnings are detected
  • Syntax Check On Save: run go build / go test on save to check for errors
  • Vet On Save: run vet on save to check for errors or warnings

Additionally, the following preferences can be optionally set:

  • Golint Args: specify the arguments that should be passed to golint
  • Go Installation: you should not need to specify this by default (!); allows you to specify a specific go installation instead of relying on inspection of the path and use of platform defaults
  • Go Path: this should usually be set in the environment, but you can specify your GOPATH here also to ensure Atom still works if you accidentally launch it via Finder, Dock, or Spotlight instead of the command line atom helper
  • Show Panel When No Issues Exist: show the message panel even if there are no errors or warnings
  • Vet Args: specify the arguments that should be passed to vet

The package will search the following locations (in order) for a go executable:

  • All directories specified in the PATH environment variable
  • OS X: /usr/local/go/bin (package installer)
  • OS X: /usr/local/bin (Homebrew)
  • Windows: C:\go\bin (package installer)

If you have go installed somewhere else, and not available on the path, specify the full path to the go executable in the Go Installation preference.

GOPATH

Love it or hate it, GOPATH is very important in go land.

Syntax checking requires a valid GOPATH for the files you are checking. You can set your GOPATH using one of two mechanisms:

  • Using the environment: set the $GOPATH environment variable to the correct value
  • Using go-plus preferences: set the Go Path preference

The environment (if set) is preferred over the Go Path preference by default. You can change this by updating the Environment Overrides Configuration preference.

The most common reason GOPATH might not be set in the environment is due to the way OS X launches processes. When you launch Atom via processes created by launchd (e.g. using Finder, the Dock, or Spotlight) it likely will not have access to your $GOPATH if you set it in your shell initialization files (e.g. .bash_profile, .bashrc, .zshrc, etc).

Consider launching Atom via your shell – using the Atom Shell Commands – where Atom should inherit your environment. Alternatively, try one of the suggestions at http://apple.stackexchange.com/a/87283 to set the GOPATH for processes launched by launchd (and their children, which will include Atom).

Setting the Go Path preference will ensure that you have a sensible fallback for GOPATH if you have launched Atom without the $GOPATH environment variable set.

If both the Go Path preference and the $GOPATH / %GOPATH% environment variable are empty, go-plus will display a warning and will not perform go build / go test powered syntax checking.

Planned Features

The following features will be added soon:

Troubleshooting

Missing Tools

Question: Why are some of the tools found, not cover, goimports, or vet?

Answer: Do you have Mercurial Installed?

Many go tools live at https://code.google.com/p/go.tools. This repository is a Mercurial repository. If you have the Get Missing Tools option enabled, go-plus will attempt to install required tools from this repository. If you do not have Mercurial (hg) installed, go-plus will not succeed in installing cover, goimports, or vet.

To resolve issues installing cover or vet, install Mercurial:

GOPATH

Question: Why can't Atom see my GOPATH? I have set it and I see it in terminal?

Answer: Did You Launch Atom Using The Shell Command?

(From Above):

The most common reason GOPATH might not be set in the environment on OS X is due to the way OS X launches processes. When you launch Atom via processes created by launchd (e.g. using Finder, the Dock, or Spotlight) it likely will not have access to your $GOPATH if you set it in your shell initialization files (e.g. .bash_profile, .bashrc, .zshrc, etc).

Consider launching Atom via your shell – using the Atom Shell Commands – where Atom should inherit your environment. Alternatively, try one of the suggestions at http://apple.stackexchange.com/a/87283 to set the GOPATH for processes launched by launchd (and their children, which will include Atom).

Still Having Issues?

If you are having issues and the information above isn't helping, feel free to create an issue at https://github.com/joefitzgerald/issues. When you create the issue, please be sure to paste the information from Packages > Go Plus > Display Go Information to help us form a response that is targeted to your situation. This looks something like:

Go: go1.3.3 darwin/amd64 (@/usr/local/bin/go)
GOPATH: /Users/jfitzgerald/go
Cover Tool: /usr/local/Cellar/go/1.3.3/libexec/pkg/tool/darwin_amd64/cover
Vet Tool: /usr/local/Cellar/go/1.3.3/libexec/pkg/tool/darwin_amd64/vet
Format Tool: /Users/jfitzgerald/go/bin/goimports
Lint Tool: /Users/jfitzgerald/go/bin/golint
Git: /usr/bin/git
Mercurial: /usr/local/Cellar/mercurial/3.1.2/bin/hg
PATH: /Users/jfitzgerald/go/bin:/usr/local/bin:/Users/jfitzgerald/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/jfitzgerald/go/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/texbin
Atom: 0.143.0 (darwin x64 14.0.0)

Contributors

A list of contributors can be found at https://github.com/joefitzgerald/go-plus/graphs/contributors. Joe Fitzgerald (@joefitzgerald) is the maintainer of this project.

Contributing

Contributions are greatly appreciated. Please fork this repository, make your changes, and open a pull request. See Contributing for detailed instructions.

Directories

Path Synopsis
examples
spec

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL