Skip to content

x/tools/cmd/goimports: provide a flag for the local import path prefix #12420

@kr

Description

@kr

My company has tried to adopt a convention placing import paths into three groups: standard library followed by third-party packages followed by local packages. For example

import (
    "database/sql"
    "io"
    "strconv"

    "github.com/lib/pq"

    "mycompany.com/foo/bar"
    "mycompany.com/foo/baz"
)

We'd like to be able to add a flag to our goimports-on-save hook, like

goimports -local mycompany.com/

to tell goimports to put any paths beginning with "mycompany.com/" into our third group. I think that would end up as group value 3 in the goimports source: stdlib=0, 3rd party=1, appengine=2, then local=3.

If this sounds reasonable, I can write a patch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions