草庐IT

string-type-overview

全部标签

go - 无法将 String 转换为 *net.TCPlistener 类型

我想将字符串放入net.Listener中,但出现错误:./server.go:26:23:cannotusemainServer(typeinterface{})astypestringinargumenttonet.Listen:needtypeassertion./server.go:27:28:cannotusegpServer(typeinterface{})astypestringinargumenttonet.Listen:needtypeassertion这是我的代码:viper.SetConfigFile("config.json")viper.AddConfigPa

go - 更新结构中的 map[string]*struct 变量

packagemainimport"fmt"typeStatestringconst(//PASScheckpassed.PASSState="PASS"//FAILcheckfailed.FAIL="FAIL"//WARNcouldnotcarryoutcheck.WARN="WARN"//INFOinformationalmessageINFO="INFO"//SKIPfortestsskippedSKIP="SKIP")//SummaryLevelWiseisasummaryofresultsofcontrolchecksrunCISLevelwisetypeSomethings

json - 读取 map[string]interface{} 中的数据

源服务器返回多个对象的Json格式的数据接口(interface),我们如何解析这些数据?我正在使用JSONmap[string]interface{}类型的变量来保存来自服务器的结果ThedatareturnfromServer."data":[{"group":"PAA_TEST","id":"2018-04-10T09:24:18.000000Z","name":"PAA_STATION","released":true,"version":33},{"group":"PAA_TEST","id":"2018-03-19T10:50:21.000000Z","name":"PAA

go - 将 map[string][]string 转换为 []map[string]interface{}

我有一个类型为map[string][]string的tmp变量,我想使用gotadaraframe的LoadMaps功能。但它只接受[]map[string]interface{}。现在我想找到一种方法将map[string][]string转换为[]map[string]interface{}。funcmain(){input:=[][]string{[]string{"b","3","abc","5.3"},[]string{"a","4","efg","9.1"},[]string{"b","4","abc","5.3"},[]string{"c","3","hij","5.5

go - x/手机 : Launch a android application with given package name [String] in go

下面是用go写的函数:funcLaunchApplication(packageNamestring){Query:howcanIexecuteapplicationwithgivenpackageName}使用gomobile生成java绑定(bind)[.aar]。我想包含在我的android应用程序中生成的.aar,并从java层调用LaunchApplication("com.package.name")到本地go层,go层应该运行该应用程序。在java应用中,使用包名运行apk的方法如下:Processprocess=Runtime.getRuntime().exec("am

go - 无效操作 : connot index static[] (value of type byte)

尝试将toml文件中设置的静态内容信息更改为使用环境变量时出现的错误问题先放对应的代码//.envvariablesSTATICS=[["web","/var/www/ichain-admin-react"],["static","static"]]//sourcecodefuncserveStaticFiles(engine*gin.Engine){statics:=os.Getenv("STATICS")fori:=0;iinvalidoperation:cannotindexstatics[i](valueoftypebyte)我没有找到任何对我有很大帮助的文章谢谢

postgresql - pq : invalid input syntax for type double precision: "$1" with Golang

我正在尝试在我的GO程序中将一个简单的INSERT插入到postgresql数据库中。我的数字0是一个float64,我的数据库中有一列需要doubleprecision。我不知道我需要将数字转换成什么才能让数据库接受该值。 最佳答案 PostgreSQL驱动程序可以很好地处理将float64插入到double列中:tmp=#\dtestTable"public.test"Column|Type|Modifiers--------+------------------+-----------v|doubleprecision|和代码

go - Golang 中 Make string 末尾的 `json:"make"` 是什么意思?

这个问题在这里已经有了答案:Whatistheusageofbacktickingolangstructsdefinition?[duplicate](2个答案)关闭6年前。我正在处理一些Golang源代码,并且对下面的程序语法感到困惑。Golang中Makestring末尾的json:"make"是什么意思?typeVehiclestruct{Makestring`json:"make"`Modelstring`json:"model"`Regstring`json:"reg"`VINint`json:"VIN"`Ownerstring`json:"owner"`Scrappedbo

go - 如何在 docker registry api 中为带有标签的图像名称创建 map[string][]string?

我正在使用DockerRegistryAPI,首先使用Listrepositories列出注册表中的所有图像方法,然后在图像中循环以创建一个map[string][]string:image[]tags使用Listingimagetags方法。我试过了funcGetImages(whttp.ResponseWriter,r*http.Request){w.Header().Set("Access-Control-Allow-Origin","*")res,err:=http.Get(fmt.Sprintf("%s/%s",sconf.RegistryConf.url,sconf.Reg

string - golang - 字符串排列 - slice 边界超出范围

Here是这个问题的GoPlayground代码。我正在尝试使用递归编写golang字符串排列。置换函数有两个参数,prefix是一个空字符串("")和str,它是"abc"。代码如下funcmain(){str:="abc"perm("",str)}funcperm(prefixstring,strstring){n:=len(str)fmt.Println(n)ifn==0{fmt.Println(prefix)}else{fori:=0;i当我运行这段代码时,如预期的那样,n的值显示为3,2,1,0。我成功获得了“abc”,但随后我收到了“panic:runtimeerror:s