草庐IT

Linux的目录结构

全部标签

docker - 无法使用 docker 存储库中 vendor 目录中的包

我正在尝试使用docker的goapi创建一个容器。我想在ContainerCreate()API中使用container.Config.ExposedPorts公开一个端口。下面是代码packagemainimport("fmt""context""github.com/docker/docker/api/types/container""github.com/docker/docker/client""github.com/docker/go-connections/nat")funcmain(){ctx:=context.Background()cli,err:=client.N

postgresql - 使用 xo 从 postgres 数据库表模式生成 DTO 结构

我只是想知道是否有人使用过xo.我有一个Postgres数据库,里面有一堆表和东西。我似乎无法使用xo从postgres表结构生成DTOstruct。这个内置的xotemplate似乎创建了一个struct,我相信xo默认使用内置模板,但我在运行时得到的都是xo--verbose--suffix'.go'pgsql://myusername:mypass@localhost:myport/mydb?sslmode=disable-ointernal/qo/models-pqo是一堆与我的项目或我的数据库中的模式完全无关的文件。 最佳答案

谷歌云数据存储层次结构树过滤子与 Go

我有一种轻微的感觉,我错过了明显的,但似乎无法弄清楚这一点。我正在将一个API从传统的MySQL数据模型迁移到CloudDatastore,并且在使用GoLibrary过滤子实体时递归构建层次结构树时遇到问题.我的模型看起来像这样:typeCountrystruct{Key*datastore.Key`datastore:"__key__"`IdintNamestringRegion[]Region}typeRegionstruct{Key*datastore.Key`datastore:"__key__"`IdintNamestringState[]State}typeStatest

go - 如何在运行 'go test' 时排除或跳过特定目录

这个问题在这里已经有了答案:Runningtestsandskippingsomepackages(1个回答)关闭3年前。gotest$(golist./...|grep-v/vendor/)-coverprofile.testCoverage.txt我正在使用上面的命令来测试文件,但是我想从测试中排除1个名为“Store”的文件夹。怎么做到的?

go - 如何从某个应用程序目录导入所有子目录?

这个问题在这里已经有了答案:importsubpackageswithgolang,byimportingparentdir?(1个回答)关闭3年前。我正在使用Golang创建一个http服务器。(我有Php开发背景。)在internal/app/model中,我计划用人工逻辑制作几个包,我希望在main.go中加载模型文件夹的所有子目录。我有以下文件夹结构:[projectfolder]\_cmd\_main.go...\_internal\_app\_model\_article\_product我在这个意义上尝试过一些但没有成功:import("[project_folder]/

database - 如何解决 go 编程语言中的数据库结构问题?

我正在尝试创建postgresql数据库结构以在Golang中自动化系统。此代码有效;packagemainimport("database/sql""fmt"_"github.com/lib/pq")funccheckError(errerror){iferr!=nil{panic(err)}}const(host="localhost"port=5432user="postgres"password="123"dbname="DatabaseName")funcmain(){psqlInfo:=fmt.Sprintf("host=%sport=%duser=%s"+"passwor

json - 无法将外部结构直接调用到 map[string]struct

我一直在努力找出在解码JSON时为map[string]struct类型调用外部结构的正确方法。当所有代码都在同一个包中时,代码可以正常工作,但是如果它正在提取导出的类型,那么Unmarshal函数似乎有错误。packageanimalstypeBirdstruct{Namestring`json:"name"`Descriptionstring`json:"description"`}packagemainimport("encoding/json""fmt""../animal")funcmain(){birdJson:=`{"birds":{"name":"eagle","des

json - Golang 如何将嵌套结构解码为一片结构

我如何在Golang中解码此json代码。我有主机名和IP地址,但没有snmpV1部分:[{"hostname":"myserver","ipaddress":"127.0.0.1","snmpVersion":1,"snmpV1":{"community":"public"}}]我有以下结构:typeDevicestruct{Hostnamestring`json:"hostname"`Ipaddressstring`json:"ipaddress"`SnmpVersionint`json:"snmpVersion"`SnmpV1credstruct{Communitystring`

golang 去测试具体目录

我想测试除static路径之外的所有其他路径中的文件。我查过资料,可以通过gotest-run,但是我一直尝试失败下面是我的项目路径结构api/...common/...static/...//exceptthis... 最佳答案 您可以使用此命令排除特定文件夹:find./-typed!-path"./static*"!-path"./.git*"-execgotest-v"{}"\; 关于golang去测试具体目录,我们在StackOverflow上找到一个类似的问题:

docker - Golang docker library - 挂载主机目录卷

我如何执行相当于:dockerrun-v/host/path:/container/pathimage:tag从Go使用官方docker客户端包?我试过不同的Mounts和Volumesclient.ContainerCreate()function的HostOption和ConfigOption结构中的选项,但不太明白。特别是Volumes成员(map[string]struct{}类型)特别难搞清楚如何使用,我找不到关于结构中应该存在哪些值的任何文档。演示我的问题的代码:packagemainimport("context""github.com/docker/docker/api