Why can't I create constant struct?
const FEED_TO_INSERT = quzx.RssFeed{ 0, "", "desc", "www.some-site.com", "upd_url", "img_title", "img_url", 0, 0, 0, 0, 0, 100, "alt_name", 1, 1, 1, "test", 100, 100, 0 }
.\rss_test.go:32: const initializer quzx.RssFeed literal is not a constant
Go does not support constants in structs. which is an invalid syntax and also has no semantic meaning. If you want to assign each game variable a game ID, you can add an unexported field to the struct, as well as a method that returns the ID value.
To declare a constant and give it a name, the const keyword is used. Constants cannot be declared using the := syntax.
Because Go does not support struct constants (emphasis mine)
There are boolean constants, rune constants, integer constants, floating-point constants, complex constants, and string constants. Rune, integer, floating-point, and complex constants are collectively called numeric constants.
Read more here: https://golang.org/ref/spec#Constants
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With