From fbb114e61ff4af3a791efa7a389f34b59801c9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20L=C3=B3pez=20Espinosa?= Date: Thu, 9 Feb 2017 11:02:18 +0000 Subject: [PATCH] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 83ad7b0..77ebb0d 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ pillJSON := Aspirin.MarshalJSON() The generated code is exactly the same as the Stringer tool plus the mentioned additions, so you can use **Enumer** where you are already using **Stringer** without any code change. -## Enum value string representation transformation +## Transforming the string representation of the enum value -Stringer tool uses the same name for enum value string representation (usually CamelCase in Go). +By default, Enumer uses the same name of the enum value for generating the string representation (usually CamelCase in Go). ```go type MyType int @@ -84,15 +84,16 @@ type MyType int name := MyTypeValue.String() // name => "MyTypeValue" ``` -Sometimes you need to use some other string representation format then CamelCase (i.e. in JSON). +Sometimes you need to use some other string representation format than CamelCase (i.e. in JSON). -To transform enum value string representation from CamelCase to snake_case or kebab-case `transform` flag could be used. +To transform it from CamelCase to snake_case or kebab-case, you can use the `transform` flag. -For example, for `enumer -type=MyType -json -transform=snake` command the next string representation will be generated: +For example, the command `enumer -type=MyType -json -transform=snake` would generate the following string representation: ```go name := MyTypeValue.String() // name => "my_type_value" ``` +**Note**: The transformation only works form CamelCase to sanake_case or kebab-case, not the other way around. ## How to use The usage of Enumer is the same as Stringer, so you can refer to the [Stringer docs](https://godoc.org/golang.org/x/tools/cmd/stringer)