Avatar ·

How to declare a constant array in Go? (with code example)

Hi everyone! I just started learning Go and ran into a problem. I need to declare an array of strings that will be used as a constant so that it cannot be modified during program execution. In other languages (like Java or C++), I would simply write `final static String[] DAYS = {...}` or `const char* DAYS[] = {...}`.\n\nIn Go, I tried to do this:\n\n```go\nconst days = [7]string{\n "Monday",\n "Tuesday",\n "Wednesday",\n "Thursday",\n "Friday",\n "Saturday",\n "Sunday",\n}\n```\n\nBut the compiler gives an error: `const initializer [7]string literal is not a constant`. I understand that in Go, constants can only be numbers, strings, and boolean values. But I really need to protect the data from accidental modification. How do I properly declare an immutable