草庐IT

private-functions

全部标签

docker - 检查 Go 中私有(private)注册表中是否存在 docker 镜像

我想知道如何在不拉取它的情况下检查私有(private)注册表中是否存在docker镜像(在eu.gcr.io中)。我有一个用golang编写的服务,它需要检查docker镜像是否存在,以验证用户传递给它的配置文件。使用godocker客户端拉取镜像,如图here,作品。但是,我不想为了检查它们是否存在而下拉图像,因为它们可能很大。我试过使用Client.ImageSearch,但他只是搜索公共(public)图像。cloud.google.com/go包似乎也没有任何用于处理容器注册表的内容。可能有this以及它包含的起重工具,但我真的很难弄清楚它是如何工作的。文档...不是很好。我

go - 替代 golang 中的 load_pem_private_key()

我在python中有这段代码privateKey=appAuth["privateKey"]passphrase=appAuth["passphrase"]fromcryptography.hazmat.primitives.serializationimportload_pem_private_keykey=load_pem_private_key(data=privateKey.encode('utf8'),password=passphrase.encode('utf8'),backend=default_backend(),)我想在golang中复制它。基本上我有这个:-"ap

function - 云函数部署问题

当我部署云函数时,出现以下错误。我正在使用gomod,我能够从我的沙箱构建和运行所有集成测试,其中一个云函数依赖使用私有(private)githubrepo,当我部署云功能时Go:github.com/myrepo/ptrie@v0.1.:gitfetch-foriginrefs/heads/:refs/heads/refs/tags/:refs/tags/在/builder/pkg/mod/cache/vcs/41e03711c0ecff6d0de8588fa6de21a2c351c59fd4b0a1b685eaaa5868c5892e:退出状态128:致命:无法读取“https:

google-app-engine - 如何允许 App Engine 验证和下载私有(private) Go 模块

我的项目使用托管在私有(private)GitHub存储库中的Go模块。那些列在我的go.mod文件中,在公共(public)文件中。在我的本地计算机上,通过在项目的本地git配置文件中使用正确的SSHkey或APItoken,我可以毫无问题地对私有(private)存储库进行身份验证。该项目在这里编译得很好。在部署(gcloudappdeploy)和云中的构建阶段,既没有考虑git配置,也没有考虑.netrc文件,所以我的项目编译在那里失败,出现身份验证错误私有(private)模块。解决该问题的最佳方法是什么?我想避免一种解决方法,即在部署的文件中包含私有(private)模块的源

go - 模板 :1: function "copyrightYear" not defined

以下代码在tmp.Execute处出现panic,提示function"copyrightYear"notdefinedimport("os""html/template""fmt")funcmain(){fm:=template.FuncMap{"copyrightYear":func()string{returnfmt.Sprintf("%d",time.Now().Year())},}tmp:=template.Must(template.New("").Parse("{{copyrightYear}}")).Funcs(fm)tmp.Execute(os.Stdout,nil)

高语 : Allocating Slice of Slices in functions results in index out of range

我一直在用Go尝试一些东西,但遇到了一个我无法解决的问题。packagemainimport"fmt"import"strconv"funcwriteHello(iint,){fmt.Printf("hello,world"+strconv.Itoa(i)+"\n")}typeSliceStructstruct{data[][]int;}func(sSliceStruct)New(){s.data=make([][]int,10);}func(sSliceStruct)AllocateSlice(iint){s.data[i]=make([]int,10);}func(sSliceSt

function - 在 Go 模板中,我可以让 Parse 工作但不能让 ParseFiles 以类似的方式工作。为什么?

我有以下代码:t,err:=template.New("template").Funcs(funcMap).Parse("Howdy{{myfunc.}}")在这种形式下一切正常。但是,如果我对ParseFiles做完全相同的事情,将上面的文本放在template.html中,这是不行的:t,err:=template.New("template").Funcs(funcMap).ParseFiles("template.html")我能够让ParseFiles以下列形式工作,但无法让Funcs生效:t,err:=template.ParseFiles("template.html")

go function input, func (req *AppendEntriesRequest) 编码(w io.Writer) (int, error) {

func(req*AppendEntriesRequest)Encode(wio.Writer)(int,error){pb:=&protobuf.AppendEntriesRequest{Term:proto.Uint64(req.Term),PrevLogIndex:proto.Uint64(req.PrevLogIndex),PrevLogTerm:proto.Uint64(req.PrevLogTerm),CommitIndex:proto.Uint64(req.CommitIndex),LeaderName:proto.String(req.LeaderName),Entri

function - 在外部函数中访问 Go 结构的值

我有以下函数声明,它可以正常工作并正确打印出来。import("fmt""github.com/google/go-github/github")funcLatestTag(user,projectstring){client:=github.NewClient(nil)releases,_,err:=client.Repositories.ListTags(user,project,nil)iferr!=nil{fmt.Printf("error:%v\n",err)}else{release:=releases[0]fmt.Printf("Version:%+v\n",*relea

function - StructScan 未知结构 slice [GO]

所以我想通过StructScan方法填充任何结构,然后将从数据库中获得的任何数据读取到我提供给测试函数的相关结构中。这个脚本不会给出任何编译错误(如果你实现了数据库连接等其他东西)但是StructScan方法仍然返回错误并告诉我它需要一个slice结构。如何创建我不知道其类型的结构片段?感谢您的任何建议。packagemainimport("database/sql""github.com/jmoiron/sqlx")vardb*sql.DBtypeAstruct{Namestring`db:"name"`}typeBstruct{Namestring`db:"name"}funcma