todayilearned

Golang Struct Field Scopes

Golang Struct Field Scopes

Struct Field Scopes Exported Fields In other languages, this would be similar to the public access qualifier. If you come from Ruby like me, this would be defining attributes with attr_accessor If the field (i.e. attribute) of the struct starts with an upper case, it would mean that that field is exported, thus accessible outside of the package. Assume we have the following files in Go project: main.go /library /book.go Enter fullscreen mode Exit fullscreen mode We would define book.go in it's own package. // library/book.go // Assume we have a package called "library" which contains a book. package library…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.