Go中的特殊软件包名称

When importing a custom sub-package named qp with

"pkgname/qp"

the compiler complains with

... imported and not used: "pkgname/qp"
... undefined: qp

so obviously it seems to have a problem with the package name qp, because when I change it to

qp "pkgname/qp"

the errors are gone.

Are there any "reserved" or invalid package names? Why is this happening?

I'm going to guess that the files in package qp don't start with a line that says

package qp

They probably specify a different package name. When a package is imported, the name in the package declaration is the one that is available under; if that doesn't match the import path, you can get errors like this.

In other words, you imported "pkgname/qp", but the compiler is calling it something else, because you called it something else in the package statement. You don't refer to somethingElse in your code, so the import is unused. Then you refer to qp, which isn't defined anywhere (even though it looks like it was), because "pkgname/qp" doesn't define qp.

The only package names with special meanings are "main", "C" and those ending in "_something" (tests and platform specific code).

You should show the code which you claim produces the error due to name.

A package name of qp is valid. For example,

package main

import "fmt"

import "local/qp"

func main() { fmt.Println(qp.QP()) }

compiles and runs without error.