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 trial

Go Language Go Language Overview Go Syntax Package Variables

Where's wrong here? :c

I have tried a twenty times and I can't figure out where is wrong

src/code.my.com/git/sales/sales.go
package sales

var total = 1234.56
report.go
package main

import(
  "fmt"
  "src/code.my.com/git/sales"
)

func main() {
  fmt.Println(sales.total)
}

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

In Go, you have to capitalize the first letter of a variable in order for it to be visible (public) between different modules.

Thus, you will need to capitalize the first letter in 'total' in both sales.go and report.go files.

Go is a cool language, I think you're going to enjoy it!

Thanks a lot Jeff, I'm completely enjoying learn go :D