dsfykqq3403 2016-05-14 14:42
浏览 10
已采纳

拉出单行标准包装的副本以进行修改

I have an idea for a minor addition I would like to make to the database/sql go package. I would like to try my change out to see how it works.

I thought that I would be able to execute this command to get a copy of the source in database/sql that I could play with:

go get github.com/golang/go/tree/master/src/database/sql

Then, I was going to change my import statement from

import "database/sql"

to

import "github.com/golang/go/tree/master/src/database/sql"

and put a debugging Printf in my local copy of the code to confirm that the new code I just pulled was being executed rather than the code in /usr/local/go.

When I try the "go get" command above, I get this error message:

$ go get github.com/golang/go/tree/master/src/database/sql
package github.com/golang/go/tree/master/src/database/sql: cannot find package "github.com/golang/go/tree/master/src/database/sql" in any of:
    /usr/local/go/src/github.com/golang/go/tree/master/src/database/sql (from $GOROOT)
    /Users/me/go/src/github.com/golang/go/tree/master/src/database/sql (from $GOPATH)
$ echo $GOPATH
/Users/me/go
$

Why doesn't this work?

I also tried doing this with the source at

https://go.googlesource.com/go/+/release-branch.go1.6/src/database/sql

That didn't work either. Then I tried downloading the tgz of the source from the link above, and untarring those files in my own $GOPATH/src/github.com/database/sql folder, then go building them there. That produced a sql.a that ran, but didn't work.

  • 写回答

2条回答 默认 最新

  • dongseshu0698 2016-05-14 17:19
    关注

    You can either build Go from source, and then modify the standard library in place, or you can vendor that particular package.

    If you have Go installed from source, after editing the package you can install the new version just like any other package with go install database/sql

    If you copy the database/sql package into a vendor directory, that copy will be built and imported in place of the version from the standard library.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog