forked from mirror/enumer
fix
This commit is contained in:
parent
ff555f73ed
commit
e3c2a6fbb2
|
@ -1,10 +1,10 @@
|
||||||
# Enumer [![GoDoc](https://godoc.org/github.com/dmarkham/enumer?status.svg)](https://godoc.org/github.com/dmarkham/enumer) [![Go Report Card](https://goreportcard.com/badge/github.com/dmarkham/enumer)](https://goreportcard.com/report/github.com/dmarkham/enumer) [![GitHub Release](https://img.shields.io/github/release/dmarkham/enumer.svg)](https://github.com/dmarkham/enumer/releases)[![Build Status](https://travis-ci.com/dmarkham/enumer.svg?branch=master)](https://travis-ci.com/dmarkham/enumer)
|
# Enumer [![GoDoc](https://godoc.org/git.internal/re/enumer?status.svg)](https://godoc.org/git.internal/re/enumer) [![Go Report Card](https://goreportcard.com/badge/git.internal/re/enumer)](https://goreportcard.com/report/git.internal/re/enumer) [![GitHub Release](https://img.shields.io/github/release/dmarkham/enumer.svg)](https://git.internal/re/enumer/releases)[![Build Status](https://travis-ci.com/dmarkham/enumer.svg?branch=master)](https://travis-ci.com/dmarkham/enumer)
|
||||||
|
|
||||||
|
|
||||||
Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
|
Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
|
||||||
It started as a fork of [Rob Pike’s Stringer tool](https://godoc.org/golang.org/x/tools/cmd/stringer)
|
It started as a fork of [Rob Pike’s Stringer tool](https://godoc.org/golang.org/x/tools/cmd/stringer)
|
||||||
maintained by [Álvaro López Espinosa](https://github.com/alvaroloes/enumer).
|
maintained by [Álvaro López Espinosa](https://github.com/alvaroloes/enumer).
|
||||||
This was again forked here as (https://github.com/dmarkham/enumer) picking up where Álvaro left off.
|
This was again forked here as (https://git.internal/re/enumer) picking up where Álvaro left off.
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -14,7 +14,7 @@ Usage of ./enumer:
|
||||||
Enumer [flags] -type T [directory]
|
Enumer [flags] -type T [directory]
|
||||||
Enumer [flags] -type T files... # Must be a single package
|
Enumer [flags] -type T files... # Must be a single package
|
||||||
For more information, see:
|
For more information, see:
|
||||||
http://godoc.org/github.com/dmarkham/enumer
|
http://godoc.org/git.internal/re/enumer
|
||||||
Flags:
|
Flags:
|
||||||
-addprefix string
|
-addprefix string
|
||||||
transform each item name by adding a prefix. Default: ""
|
transform each item name by adding a prefix. Default: ""
|
||||||
|
@ -198,7 +198,7 @@ name := MyTypeValue.String() // name => "my_type_value"
|
||||||
For a module-aware repo with `enumer` in the `go.mod` file, generation can be called by adding the following to a `.go` source file:
|
For a module-aware repo with `enumer` in the `go.mod` file, generation can be called by adding the following to a `.go` source file:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
//go:generate go run github.com/dmarkham/enumer -type=YOURTYPE
|
//go:generate go run git.internal/re/enumer -type=YOURTYPE
|
||||||
```
|
```
|
||||||
|
|
||||||
There are four boolean flags: `json`, `text`, `yaml` and `sql`. You can use any combination of them (i.e. `enumer -type=Pill -json -text`),
|
There are four boolean flags: `json`, `text`, `yaml` and `sql`. You can use any combination of them (i.e. `enumer -type=Pill -json -text`),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
1. Go get enumer `go get -u github.com/dmarkham/enumer`
|
1. Go get enumer `go get -u git.internal/re/enumer`
|
||||||
2. `go generate` This should create `pill_enumer.go`
|
2. `go generate` This should create `pill_enumer.go`
|
||||||
3. `go run *.go` to see it in action
|
3. `go run *.go` to see it in action
|
||||||
4. `go mod tidy` to remove the deps for `enumer` once your happy.
|
4. `go mod tidy` to remove the deps for `enumer` once your happy.
|
||||||
|
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
//go:generate go run github.com/dmarkham/enumer -type=Pill -json
|
//go:generate go run git.internal/re/enumer -type=Pill -json
|
||||||
type Pill int
|
type Pill int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module github.com/dmarkham/enumer
|
module git.internal/re/enumer
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/pascaldekloe/name v1.0.0
|
github.com/pascaldekloe/name v1.0.0
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
|
// Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
|
||||||
// It started as a fork of Rob Pike’s Stringer tool
|
// It started as a fork of Rob Pike’s Stringer tool
|
||||||
//
|
//
|
||||||
// Please visit http://github.com/dmarkham/enumer for a comprehensive documentation
|
// Please visit http://git.internal/re/enumer for a comprehensive documentation
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -71,7 +71,7 @@ func Usage() {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "\tEnumer [flags] -type T [directory]\n")
|
_, _ = fmt.Fprintf(os.Stderr, "\tEnumer [flags] -type T [directory]\n")
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "\tEnumer [flags] -type T files... # Must be a single package\n")
|
_, _ = fmt.Fprintf(os.Stderr, "\tEnumer [flags] -type T files... # Must be a single package\n")
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "For more information, see:\n")
|
_, _ = fmt.Fprintf(os.Stderr, "For more information, see:\n")
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "\thttp://godoc.org/github.com/dmarkham/enumer\n")
|
_, _ = fmt.Fprintf(os.Stderr, "\thttp://godoc.org/git.internal/re/enumer\n")
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "Flags:\n")
|
_, _ = fmt.Fprintf(os.Stderr, "Flags:\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue