~sircmpwn/public-inbox

go-bare: ast: add String method to TypeKind to ease future debugging v1 APPLIED

John Mulligan: 1
 ast: add String method to TypeKind to ease future debugging

 1 files changed, 59 insertions(+), 0 deletions(-)
#364546 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/public-inbox/patches/15904/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH go-bare] ast: add String method to TypeKind to ease future debugging Export this patch

Making the (largish) enum of TypeKind meet the Stringer interface
makes it easier to map the value of the enum to "what is is".
I found this tweak eased my debugging of a failure to generate
from a bare schema file.

Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
---
 schema/ast.go | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/schema/ast.go b/schema/ast.go
index aae73d8..d016eba 100644
--- a/schema/ast.go
+++ b/schema/ast.go
@@ -92,6 +92,65 @@ const (
	UserType
)

func (tk TypeKind) String() string {
	switch tk {
	case UINT:
		return "UINT";
	case U8:
		return "U8";
	case U16:
		return "U16";
	case U32:
		return "U32";
	case U64:
		return "U64";
	case INT:
		return "INT";
	case I8:
		return "I8";
	case I16:
		return "I16";
	case I32:
		return "I32";
	case I64:
		return "I64";
	case F32:
		return "F32";
	case F64:
		return "F64";
	case Bool:
		return "Bool";
	case String:
		return "String";
	case Void:
		return "Void";
	case Data:
		return "Data";
	case DataFixed:
		return "DataFixed";
	case Array:
		return "Array";
	case Slice:
		return "Slice";
	case Optional:
		return "Optional";
	case DataArray:
		return "DataArray";
	case DataSlice:
		return "DataSlice";
	case Map:
		return "Map";
	case Union:
		return "Union";
	case Struct:
		return "Struct";
	case UserType:
		return "UserType";
	default:
		return "?"
	}
}

type Type interface {
	Kind() TypeKind
}
-- 
2.26.2
Thanks!

To git@git.sr.ht:~sircmpwn/go-bare
   cddb037..524dbe9  master -> master