Relative Content

Tag Archive for go

Golang how to get all of list const enum?

type EnglishText string const ( EnglishTextHello EnglishText = “hello” EnglishTextGoodbye EnglishText = “goodbye” EnglishTextGreeting EnglishText = “greeting” ) I have enum list constant sample My question is how to dynamic get all enum in EnglishText Ex: use for loop Thanks go You can’t directly. You can do it with code generation (eg: using go generate). […]

How to POST to GO HTTP server with size of the json unknow

I have HTTP server with a POST method in GO language and Im trying to tie it to the call from another service, but the size and structure of a json is unknown, or can vary. One call can be 10 repeated db model structs, but the next one can have be a struct where it has more fields and could have a different number of stucts in a single call – say 20. How do I go about unmarshalling it and shoving it into a database?