Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 950 Bytes

imports.md

File metadata and controls

39 lines (27 loc) · 950 Bytes

Goimports

In the imports ( .. ) section of each Go file, imports should be separated into at least three sections:

  1. standard library packages
  2. external packages
  3. local packages

This is not verified or enforced automatically, as doing so is very inefficient. Instead, please configure your editor to keep imports properly sorted, as described below.

Editor / IDE Support

The goimports tool supports a "local packages" section. Use the flag -local github.com/DataDog/datadog-agent.

Here's how to configure this for a few popular editors. Please feel free to add instructions for your favorite editor!

Vim

In vim, using vim-go, add

let g:go_fmt_options = {
\ 'goimports': '-local github.com/DataDog/datadog-agent',
\ }

VSCode

{
  "gopls": {
    "formatting.local": "github.com/DataDog/datadog-agent"
  } 
}

See https://github.com/golang/vscode-go/wiki/features#format-and-organize-imports.