Standard library / go/build

go/build.IsLocalImport()

Reports whether an import path uses local relative syntax. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func IsLocalImport(path string) bool

Parameters & Attributes

NameTypeDescription
pathstringPackage import path.

Return Value

bool

Reports whether an import path uses local relative syntax.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/build")
func main() { fmt.Println(build.IsLocalImport("./demo"), build.IsLocalImport("fmt")) }
Go Reference