Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPichaya Prasertsung
843 Points[ Go language Challenge task ] undefined: sales.total
I try to print sales.total but I get an error "undefined: sales.total" What's wrong with my code?
package sales
var total float32 = 1234.56
package main
import(
"fmt"
"code.my.com/git/sales"
)
func main() {
fmt.Println(sales.total)
}
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! Remember that for a variable to be "exported" or visible to other Go packages the name must be capitalized. Otherwise, it will only be visible inside that package.
Hope this helps!
Pichaya Prasertsung
843 PointsPichaya Prasertsung
843 PointsThis helps me a lot. Thank you so much !!