Skip to content

Commit

Permalink
Add support for string enums (#124)
Browse files Browse the repository at this point in the history
* add support for string enums
  • Loading branch information
abice authored Aug 3, 2022
1 parent f579af1 commit bc24b10
Show file tree
Hide file tree
Showing 25 changed files with 1,969 additions and 28 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ deps: $(GOIMPORTS)
PACKAGES='./generator' './_example'

.PHONY: all
all: build fmt test example cover install
all: build fmt test example cover install assets

build: deps
$(GO) generate ./generator
Expand All @@ -52,6 +52,7 @@ fmt:

test: gen-test generate
$(GO) test -v -race -coverprofile=coverage.out ./...
$(GO) test -v -race ./_example

cover: gen-test test
$(GO) tool cover -html=coverage.out -o coverage.html
Expand All @@ -61,11 +62,11 @@ coveralls: $(GOVERALLS)
$(GOVERALLS) -coverprofile=coverage.out -service=$(SERVICE) -repotoken=$(COVERALLS_TOKEN)

clean:
$(GO) clean
rm -f bin/go-enum
rm -rf coverage/
rm -rf bin/
rm -rf dist/
$(GO) clean

.PHONY: assert-no-changes
assert-no-changes:
Expand Down Expand Up @@ -102,12 +103,15 @@ bin/goveralls: go.sum
bin/go-bindata: go.sum
$(call goinstall,github.com/kevinburke/go-bindata/go-bindata)

generate1_15: generator/assets/assets.go generator/enum.tmpl
assets: generator/enum.tmpl generator/enum_string.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'
snapshots: snapshots_1.17
snapshots: snapshots_1.18

snapshots_%:
echo "##### updating snapshots for golang $* #####"
docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:$* -c './update-snapshots.sh || true'

.PHONY: ci
ci: docker_1.14
Expand All @@ -118,4 +122,4 @@ ci: docker_1.18

docker_%:
echo "##### testing golang $* #####"
docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:$* -c 'make clean && make'
docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:$* -c 'make clean && make'
6 changes: 6 additions & 0 deletions _example/strings_only.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:generate ../bin/go-enum -f=$GOFILE --ptr --marshal --flag --nocase --mustparse --sqlnullstr --sql --names

package example

// ENUM(pending, running, completed, failed)
type StrState string
208 changes: 208 additions & 0 deletions _example/strings_only_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc24b10

Please sign in to comment.