mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-04-18 17:28:06 +08:00
24 lines
456 B
Go
24 lines
456 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"go/build"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestPackage(t *testing.T) {
|
|
currentDir, _ := os.Getwd()
|
|
workDir, _ := filepath.Abs(currentDir)
|
|
fmt.Printf("[+] 工作目录 %s\n", workDir)
|
|
pkgDir := filepath.Join(workDir, "pkg/errorx")
|
|
pkg, err := build.Default.Import(pkgDir, pkgDir, build.FindOnly|build.ImportComment)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
fmt.Printf("%#v\n", pkg)
|
|
fmt.Printf("%#v\n", pkg.Name)
|
|
}
|