mirror of https://github.com/dmarkham/enumer.git
Fix imports for Go 1.5+
Particularly important for 1.6+, since the deprecated imports have been removed entirely. Fixed by syncing with upstream stringer (includes some other minor fixes/modifications).
This commit is contained in:
parent
986f3e9353
commit
76567ab639
16
stringer.go
16
stringer.go
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.5
|
||||
|
||||
// Stringer is a tool to automate the creation of methods that satisfy the fmt.Stringer
|
||||
// interface. Given the name of a (signed or unsigned) integer type T that has constants
|
||||
// defined, stringer will create a new self-contained Go source file implementing
|
||||
|
@ -64,20 +66,18 @@ import (
|
|||
"fmt"
|
||||
"go/ast"
|
||||
"go/build"
|
||||
exact "go/constant"
|
||||
"go/format"
|
||||
"go/importer"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/exact"
|
||||
"golang.org/x/tools/go/types"
|
||||
|
||||
_ "golang.org/x/tools/go/gcimporter"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -90,7 +90,7 @@ var (
|
|||
func Usage() {
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "\tstringer [flags] -type T [directory]\n")
|
||||
fmt.Fprintf(os.Stderr, "\tstringer [flags[ -type T files... # Must be a single package\n")
|
||||
fmt.Fprintf(os.Stderr, "\tstringer [flags] -type T files... # Must be a single package\n")
|
||||
fmt.Fprintf(os.Stderr, "For more information, see:\n")
|
||||
fmt.Fprintf(os.Stderr, "\thttp://godoc.org/golang.org/x/tools/cmd/stringer\n")
|
||||
fmt.Fprintf(os.Stderr, "Flags:\n")
|
||||
|
@ -129,7 +129,7 @@ func main() {
|
|||
}
|
||||
|
||||
// Print the header and package clause.
|
||||
g.Printf("// Code generated by \"stringer %s\"; DO NOT EDIT\n", strings.Join(os.Args[1:], " "))
|
||||
g.Printf("// Code generated by \"enumer %s\"; DO NOT EDIT\n", strings.Join(os.Args[1:], " "))
|
||||
g.Printf("\n")
|
||||
g.Printf("package %s", g.pkg.name)
|
||||
g.Printf("\n")
|
||||
|
@ -264,7 +264,7 @@ func (g *Generator) parsePackage(directory string, names []string, text interfac
|
|||
// check type-checks the package. The package must be OK to proceed.
|
||||
func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {
|
||||
pkg.defs = make(map[*ast.Ident]types.Object)
|
||||
config := types.Config{FakeImportC: true}
|
||||
config := types.Config{Importer: importer.Default(), FakeImportC: true}
|
||||
info := &types.Info{
|
||||
Defs: pkg.defs,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue