i am struggling with the initiation of a slice in a struct (GO-language). This may be easy, but still I can not solve it. I get
syntax error: unexpected var, expecting }
./test.go:28: no new variables on left side of :=
./test.go:29: non-name g.s on left side of := is the code;
I believe that s should be declared as part of the struct, so wonder why I get that error. Someone got some advice?
package main
import "fmt"
type node struct {
value int
}
type graph struct {
nodes , edges int
var s []int
}
func main() {
g:= graphCreate()
}
func input(tname string)(number int){
fmt.Println("input a number of " + tname)
fmt.Scan(&number)
return
}
func graphCreate()(g graph){
g:= graph{input("nodes"), input("edges")}
g.s := make([]int, 100)
return
}