I did not know how to create a package and how to use it. I am using liteid and go 1.4.2, but this is all reproduction-able from the command line. I'm able to make it a size package but it does not load from the main package.
GOPATH = D: \ src \ teaching \ golang GOROOT = c: \ go + teaching \ Golang \ pkg \ windows_386 size. A \ src \ packages package.go \ shape shape.go install shape - & gt; Make shapes. Prepare the package packages.go # package.d: \ src \ education \ golang \ src \ packages \ packages.go: 5: imported and not used: "size" D: \ src \ teaching \ golang \ src \ package \ Packages.go: 8: Undefined: Size D: \ src \ teaching \ golang \ src \ packages \ packages.go: 1 9: Undefined: circle
shape.go
packages.go
... shape ) Float64 {sum: = float64 (0) _, v: = class size {sum + = v.Area ()} return amount} func main () {circle: = circle {x: 1, y: 2, radius : 2} FMT print
Any ideas?
Size
is defined in the shape package, you must reference it as shape.Shape
No comments:
Post a Comment