Golang "enum" i dont have iota but string

I followed a tutorial, but all the types were of values ​​int, someone could help me how to manage it?
The value I enter is ‘Maggio’ and the value to display is ‘E’

type Month string
const (
	Gennaio   Month = "A"
	Febbraio  Month = "B"
	Marzo     Month = "C"
	Aprile    Month = "D"
	Maggio    Month = "E"
	Giugno    Month = "H"
	Luglio    Month = "L"
	Agosto    Month = "M"
	Settembre Month = "P"
	Ottobre   Month = "R"
	Novembre  Month = "S"
	Dicembre  Month = "T"

var months= []string{"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"}

You mean as in this golang-playground?

Or maybe this?


1 Like

Thank u
But i have month as field in a struct? It should function it? Because i tried, but didn’t return the value “E”

Can you give an example code?

To the end, i tried and function it
Thank u everbody <3

I resolved

thank u

It is always helpful for other people which have similar problems, when you post a short wrap up of your problem and how you were able to solve it finally.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.