Skip to content

Instantly share code, notes, and snippets.

@Huholoman
Created January 14, 2020 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Huholoman/0917cf5b3947790dde747a1fc2bc0693 to your computer and use it in GitHub Desktop.
Save Huholoman/0917cf5b3947790dde747a1fc2bc0693 to your computer and use it in GitHub Desktop.
./main.go:19:20: foo.Name undefined (type int has no field or method Name)
GNU nano 4.7 main.go Změněno
package main
import "fmt"
type Foo struct {
Name string
}
func getSlices() []Foo {
return []Foo{
{Name: "Foo"},
{Name: "Boo"},
}
}
func main() {
foos := getSlices()
for foo := range foos {
fmt.Println(foo.Name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment