mirror of https://github.com/dmarkham/enumer.git
Updated README with syntax highlighting for Go snippets
This commit is contained in:
parent
ce36ee186f
commit
a8751cee5a
|
@ -8,7 +8,7 @@ from a REST API request... In short, from those places where using the real enum
|
||||||
be almost meaningless or hard to trace or use by a human
|
be almost meaningless or hard to trace or use by a human
|
||||||
|
|
||||||
For example, if we have an enum type called `Pill`,
|
For example, if we have an enum type called `Pill`,
|
||||||
```
|
```go
|
||||||
type Pill int
|
type Pill int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -20,7 +20,7 @@ const (
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
executing `enumer -type=Pill` will generate a new file with two methods:
|
executing `enumer -type=Pill` will generate a new file with two methods:
|
||||||
```
|
```go
|
||||||
func (i Pill) String() string {
|
func (i Pill) String() string {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func PillString(s string) (Pill, error) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
From now on, we can:
|
From now on, we can:
|
||||||
```
|
```go
|
||||||
// Convert any Pill value to string
|
// Convert any Pill value to string
|
||||||
var aspirinString string = Aspirin.String()
|
var aspirinString string = Aspirin.String()
|
||||||
// (or use it in any place where a Stringer is accepted)
|
// (or use it in any place where a Stringer is accepted)
|
||||||
|
|
Loading…
Reference in New Issue