dspld86684 2016-08-26 16:30
浏览 75

GoLang小姐链接静态库

Running a go run main.go I get a strange error message:

danilo@lm ~/godev/src/quick $ go run main.go 
command-line-arguments
/usr/lib/go-1.6/pkg/tool/linux_amd64/link: cannot open file /usr/lib/go-1.6/pkg/linux_amd64/github.com/valyala/quicktemplate.a: open /usr/lib/go-1.6/pkg/linux_amd64/github.com/valyala/quicktemplate.a: no such file or directory`

Here is my enviroment:

Linux Mint 18

GOLANG ENV:

danilo@lm ~/godev/src/quick $ go env
GOARCH="amd64"
GOBIN="/home/danilo/godev/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/danilo/godev"
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

My $GOPATH tree:

.(godev)
├── bin
│   └── qtc
├── pkg
│   └── linux_amd64
│       └── github.com
│           └── valyala
│               ├── bytebufferpool.a
│               └── quicktemplate.a
└── src
    ├── github.com
    │   └── valyala
    │       ├── bytebufferpool
    │       │   ├── ...
    │       └── quicktemplate
    │           ├── ...
    └── quick
        ├── main.go
        └── templates
            ├── hello.qtpl
            └── hello.qtpl.go

It seems like to miss the pkg folder in my workspace where the static libraries are stored!
Am I right?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douyang5943 2016-08-26 16:41
    关注

    Sorry, I solved. The main.go code was:

    package main
    
    import (
        "fmt"
    
        "./templates"
    )
    
    func main() {
        fmt.Printf("%s
    ", templates.Hello("Foo"))
        fmt.Printf("%s
    ", templates.Hello("Bar"))
    }
    

    so I missed to use absolute path in the import section:

    package main
    
    import (
        "fmt"
    
        "quick/templates"
    )
    
    func main() {
        fmt.Printf("%s
    ", templates.Hello("Foo"))
        fmt.Printf("%s
    ", templates.Hello("Bar"))
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题