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

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"
)