Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Go Go Language Overview Go Syntax Package Variables

Cannot find package

Hello fellow coders out there. I am having issues with this problem, as it claims that:

report.go:5:3: cannot find package "src/code.my.com/git/sales/sales" in any of: /usr/local/go/src/src/code.my.com/git/sales/sales (from $GOROOT) /workdir/src/src/code.my.com/git/sales/sales (from $GOPATH)

Can you please help? My code seems perfectly okay.

Thank you for reading this post.

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/sales.go"
)

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

1 Answer

Paul Harrison
Paul Harrison
5,533 Points

Hey Alexander -

The import line doesn't need to include the specific .go file, just the package name. It also doesn't need the "src" directory because that's part of the default path Go will look in.

Your import should look like this:

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