Skip to content

cmd/gofmt: align renamed imports #32189

@dsnet

Description

@dsnet

Currently, my import block looks something like:

import (
	"bytes"
	"math"
	"reflect"
	"testing"

	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"google.golang.org/protobuf/internal/encoding/pack"
	pimpl "google.golang.org/protobuf/internal/impl"
	"google.golang.org/protobuf/internal/pragma"
	ptype "google.golang.org/protobuf/internal/prototype"
	"google.golang.org/protobuf/internal/scalar"
	pref "google.golang.org/protobuf/reflect/protoreflect"
	preg "google.golang.org/protobuf/reflect/protoregistry"
	piface "google.golang.org/protobuf/runtime/protoiface"

	proto2_20180125 "google.golang.org/protobuf/internal/testprotos/legacy/proto2.v1.0.0-20180125-92554152"
)

Most of the import paths have a shared prefix, but the lack of aligning makes this hard to see. Preferably, gofmt would align the imports like:

import (
	"bytes"
	"math"
	"reflect"
	"testing"

	       "github.com/google/go-cmp/cmp"
	       "github.com/google/go-cmp/cmp/cmpopts"
	       "google.golang.org/protobuf/internal/encoding/pack"
	pimpl  "google.golang.org/protobuf/internal/impl"
	       "google.golang.org/protobuf/internal/pragma"
	ptype  "google.golang.org/protobuf/internal/prototype"
	       "google.golang.org/protobuf/internal/scalar"
	pref   "google.golang.org/protobuf/reflect/protoreflect"
	preg   "google.golang.org/protobuf/reflect/protoregistry"
	piface "google.golang.org/protobuf/runtime/protoiface"

	proto2_20180125 "google.golang.org/protobuf/internal/testprotos/legacy/proto2.v1.0.0-20180125-92554152"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions