Repository: abice/go-enum (go)

Issue:
Text after ) will be included in the last enum value
When adhering to godot linter rules, I must add a trailing `.` to the end of the `ENUM(...)`. But this will result in `).` to be added to the string name:

```go
// ENUM(1).
type Test int8
```
generates
```go
const (
	// Test1 is a Test of type 1)..
	Test1 Test = iota
)

const _TestName = "1)."
```

But even worse, on a multiline variant, it will add an empty item, colliding with the type:

```go
// ENUM(
//   X
//   Y
//   Z
// ).
type Test int8
```
generates
```go
const (
	// TestX is a Test of type X.
	TestX Test = iota
	// TestY is a Test of type Y.
	TestY
	// TestZ is a Test of type Z.
	TestZ
	// Test is a Test of type )..
	Test
)

const _TestName = "XYZ)."
```

I tried (to no avail) to disable godot for the ENUM line, since I find it a bit pointless. However, this does mean that it's also not possible to add some text behind the closing `)` which may be useful. Especially considering `ENUM(...values...)` kinda implies that parsing stops at `)`

Pull request description:
fix parsing
Fixes #102 

Patch:
diff --git a/Makefile b/Makefile
index 96cf2b4..9a17b87 100644
--- a/Makefile
+++ b/Makefile
@@ -105,6 +105,10 @@ bin/go-bindata: go.sum
 generate1_15: generator/assets/assets.go generator/enum.tmpl
 	docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:1.15 -c 'make clean $(GOBINDATA) && $(GO) generate ./generator && make clean'
 
+.PHONY: snapshots1_18
+snapshots1_18:
+	docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:1.18 -c './update-snapshots.sh || true && make clean && make'
+
 .PHONY: ci
 ci: docker_1.14
 ci: docker_1.15
diff --git a/example/animal.go b/example/animal.go
index 84799d4..02c177a 100644
--- a/example/animal.go
+++ b/example/animal.go
@@ -8,5 +8,5 @@ package example
 // Fish
 // Fish++
 // Fish#
-// )
+// ).
 type Animal int32
diff --git a/generator/generator.go b/generator/generator.go
index 13e3689..c45b6bd 100644
--- a/generator/generator.go
+++ b/generator/generator.go
@@ -469,6 +469,12 @@ func getEnumDeclFromComments(comments []*ast.Comment) string {
 			enumParamLevel += paramLevel
 			if enumParamLevel == 0 {
 				// End ENUM Declaration
+				if trimmed != "" {
+					end := strings.Index(trimmed, ")")
+					if end >= 0 {
+						parts[len(parts)-1] = trimmed[:end]
+					}
+				}
 				break
 			}
 		}


Test patch:
diff --git a/generator/.snapshots/Test118CustomPrefixExampleFile-og b/generator/.snapshots/Test118CustomPrefixExampleFile-og
index 531abf3..8b0acde 100644
--- a/generator/.snapshots/Test118CustomPrefixExampleFile-og
+++ b/generator/.snapshots/Test118CustomPrefixExampleFile-og
@@ -833,7 +833,7 @@
   (string) (len=60) "\t// Custom_prefix_Green is a ColorWithComment of type Green.",
   (string) (len=20) "\tCustom_prefix_Green",
   (string) (len=58) "\t// Custom_prefix_Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=48) "\tCustom_prefix_Blue ColorWithComment = iota + 29",
   (string) (len=58) "\t// Custom_prefix_Grey is a ColorWithComment of type Grey.",
   (string) (len=19) "\tCustom_prefix_Grey",
diff --git a/generator/.snapshots/Test118ExampleFile-og b/generator/.snapshots/Test118ExampleFile-og
index 559ddad..274740c 100644
--- a/generator/.snapshots/Test118ExampleFile-og
+++ b/generator/.snapshots/Test118ExampleFile-og
@@ -493,7 +493,7 @@
   (string) (len=62) "\t// ColorWithCommentGreen is a ColorWithComment of type Green.",
   (string) (len=22) "\tColorWithCommentGreen",
   (string) (len=60) "\t// ColorWithCommentBlue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=50) "\tColorWithCommentBlue ColorWithComment = iota + 29",
   (string) (len=60) "\t// ColorWithCommentGrey is a ColorWithComment of type Grey.",
   (string) (len=21) "\tColorWithCommentGrey",
diff --git a/generator/.snapshots/Test118NoPrefixExampleFile-og b/generator/.snapshots/Test118NoPrefixExampleFile-og
index c263fa4..5c84585 100644
--- a/generator/.snapshots/Test118NoPrefixExampleFile-og
+++ b/generator/.snapshots/Test118NoPrefixExampleFile-og
@@ -267,7 +267,7 @@
   (string) (len=46) "\t// Green is a ColorWithComment of type Green.",
   (string) (len=6) "\tGreen",
   (string) (len=44) "\t// Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=34) "\tBlue ColorWithComment = iota + 29",
   (string) (len=44) "\t// Grey is a ColorWithComment of type Grey.",
   (string) (len=5) "\tGrey",
diff --git a/generator/.snapshots/Test118NoPrefixExampleFileWithSnakeToCamel-og b/generator/.snapshots/Test118NoPrefixExampleFileWithSnakeToCamel-og
index 59670ee..f6e5506 100644
--- a/generator/.snapshots/Test118NoPrefixExampleFileWithSnakeToCamel-og
+++ b/generator/.snapshots/Test118NoPrefixExampleFileWithSnakeToCamel-og
@@ -267,7 +267,7 @@
   (string) (len=46) "\t// Green is a ColorWithComment of type Green.",
   (string) (len=6) "\tGreen",
   (string) (len=44) "\t// Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=34) "\tBlue ColorWithComment = iota + 29",
   (string) (len=44) "\t// Grey is a ColorWithComment of type Grey.",
   (string) (len=5) "\tGrey",
diff --git a/generator/.snapshots/TestCustomPrefixExampleFile b/generator/.snapshots/TestCustomPrefixExampleFile
index 531abf3..8b0acde 100644
--- a/generator/.snapshots/TestCustomPrefixExampleFile
+++ b/generator/.snapshots/TestCustomPrefixExampleFile
@@ -833,7 +833,7 @@
   (string) (len=60) "\t// Custom_prefix_Green is a ColorWithComment of type Green.",
   (string) (len=20) "\tCustom_prefix_Green",
   (string) (len=58) "\t// Custom_prefix_Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=48) "\tCustom_prefix_Blue ColorWithComment = iota + 29",
   (string) (len=58) "\t// Custom_prefix_Grey is a ColorWithComment of type Grey.",
   (string) (len=19) "\tCustom_prefix_Grey",
diff --git a/generator/.snapshots/TestExampleFile b/generator/.snapshots/TestExampleFile
index 559ddad..274740c 100644
--- a/generator/.snapshots/TestExampleFile
+++ b/generator/.snapshots/TestExampleFile
@@ -493,7 +493,7 @@
   (string) (len=62) "\t// ColorWithCommentGreen is a ColorWithComment of type Green.",
   (string) (len=22) "\tColorWithCommentGreen",
   (string) (len=60) "\t// ColorWithCommentBlue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=50) "\tColorWithCommentBlue ColorWithComment = iota + 29",
   (string) (len=60) "\t// ColorWithCommentGrey is a ColorWithComment of type Grey.",
   (string) (len=21) "\tColorWithCommentGrey",
diff --git a/generator/.snapshots/TestNoPrefixExampleFile b/generator/.snapshots/TestNoPrefixExampleFile
index c263fa4..5c84585 100644
--- a/generator/.snapshots/TestNoPrefixExampleFile
+++ b/generator/.snapshots/TestNoPrefixExampleFile
@@ -267,7 +267,7 @@
   (string) (len=46) "\t// Green is a ColorWithComment of type Green.",
   (string) (len=6) "\tGreen",
   (string) (len=44) "\t// Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=34) "\tBlue ColorWithComment = iota + 29",
   (string) (len=44) "\t// Grey is a ColorWithComment of type Grey.",
   (string) (len=5) "\tGrey",
diff --git a/generator/.snapshots/TestNoPrefixExampleFileWithSnakeToCamel b/generator/.snapshots/TestNoPrefixExampleFileWithSnakeToCamel
index 59670ee..f6e5506 100644
--- a/generator/.snapshots/TestNoPrefixExampleFileWithSnakeToCamel
+++ b/generator/.snapshots/TestNoPrefixExampleFileWithSnakeToCamel
@@ -267,7 +267,7 @@
   (string) (len=46) "\t// Green is a ColorWithComment of type Green.",
   (string) (len=6) "\tGreen",
   (string) (len=44) "\t// Blue is a ColorWithComment of type Blue.",
-  (string) (len=23) "\t// Blue starts with 33",
+  (string) (len=24) "\t// Blue starts with 33.",
   (string) (len=34) "\tBlue ColorWithComment = iota + 29",
   (string) (len=44) "\t// Grey is a ColorWithComment of type Grey.",
   (string) (len=5) "\tGrey",
diff --git a/generator/example_test.go b/generator/example_test.go
index e90e82c..a6d4d33 100644
--- a/generator/example_test.go
+++ b/generator/example_test.go
@@ -11,14 +11,14 @@ type X struct {
 // Blue=33
 // grey=
 // yellow
-// )
+// ).
 type Color int
 
 // Animal x ENUM(
 // Cat,
 // Dog,
 // Fish
-// )
+// ) Some other line of info
 type Animal int32
 
 // Model x ENUM(Toyota,_,Chevy,_,Ford)
@@ -28,7 +28,7 @@ type Model int32
  Coke
  Pepsi
  MtnDew
-)
+).
 */
 type Soda int64
 
@@ -62,7 +62,7 @@ type StartNotZero int64
 // ENUM(
 // Black, White, Red
 // Green
-// Blue=33 // Blue starts with 33
+// Blue=33 // Blue starts with 33.
 // grey=
 // yellow
 // )