草庐IT

Ubuntu-bash

全部标签

bash - 去工具 vert 。 |& grep -v vendor ;真

all:gotool@gobuild-v.clean:rm-fapiserverfind.-name"[._]*.s[a-w][a-z]"|xargs-irm-f{}gotool:gofmt-w.gotoolvet.|&grep-vvendor;truehelp:@echo"make-compilethesourcecode"@echo"makeclean-removebinaryfileandvimswpfiles"@echo"makegotool-rungotool'fmt'and'vet'"@echo"makeca-generatecafiles".PHONY:cleangoto

go - 无法在ubuntu中为golang编译proto文件

我已经安装了这些包:google.golang.org/grpcgithub.com/golang/protobuf/protoc-gen-go导出路径如下:exportPATH=$PATH:/usr/local/go/bin当我尝试使用protoc命令编译proto文件时,我看到命令未找到错误:protoc--go_out=.helloworld/helloworld.protozsh:commandnotfound:protoc我的项目路径是这样的:/home/my-username/go/src/github.com/my-username/helloworld我的go版本:go

docker - 从 Ubuntu amd64 到 arm7l : exec user process caused "exec format error" 进行交叉编译

从amd64到arm7l的交叉编译让我头疼我终于可以用GitlabCI做到这一点,所以现在,我在docker镜像中编译我的二进制文件,这是dockerfile:FROMgolangWORKDIR/go/src/gitlab.com/company/edge_to_bcCOPY..RUNdpkg--add-architecturearmhf&&aptupdate&&apt-getinstall-ygcc-arm-linux-gnueabihflibltdl-dev:armhf我将其构建为然后我将使用名称ubuntu:cross-compil构建新容器“cross-compil”现在,我可

bash - exec.Command 卡在包含 nohup 的 Bash 脚本上

当我使用Go的exec.Command{}时执行一些包含nohup的bash脚本,它将永远挂起。我不知道ping和ifconfig有什么区别。我尝试重定向标准输入()、标准输出(>/dev/null)和标准错误(2>/dev/null)以及它们的组合,其中一些有效,一些无效。当我使用sh时执行脚本,它会立即结束。Go代码:packagemainimport("fmt""os/exec")funcmain(){cmd:=exec.Command("sh","a.sh")out,err:=cmd.Output()//Orcmd.CombinedOutput()fmt.Println(str

bash - os.exec.Command 和 pbcopy

我正在尝试执行bash命令"helloworld"|/usr/bin/pbcopy里面Go:packagemainimport("fmt""os/exec""strings")funcCmd(cmdstring){fmt.Println("commandis",cmd)parts:=strings.Fields(cmd)head:=parts[0]parts=parts[1:len(parts)]out,err:=exec.Command(head,parts...).Output()iferr!=nil{fmt.Printf("%s",err)}fmt.Println("out")f

ubuntu - GOPATH 设置不正确

我是在xubuntu上安装的。之后,我更改了GOPATH$exportGOPATH=$HOME/go$echo$GOPATH$/home/rangga/go如果我真的去运行$gorun/home/rangga/go/src/Test/testpath.go$/home/rangga我使用os.Getwd()来测试当前路径应该是这样的输出/home/rangga/go/src/Test仅供引用,这是我的环境GOARCH="amd64"GOBIN=""GOCHAR="6"GOEXE=""GOHOSTARCH="amd64"GOHOSTOS="linux"GOOS="linux"GOPATH

ubuntu - goLang 依赖项的问题

我正在尝试编译以下githubproject,但是我遇到了依赖项问题。以下goget命令失败并出现以下错误goget-ugithub.com/go-gl/glfw/v3.1/glfw失败并出现以下情况:#github.com/go-gl/glfw/v3.1/glfwInfileincludedfrom/home/bob/go/src/github.com/go-gl/glfw/v3.1/glfw/context.go:4:0:glfw/include/GLFW/glfw3.h:153:21:fatalerror:GL/gl.h:Nosuchfileordirectorycompilat

go - 在 ubuntu 14.04 上为 golang 安装 protobuf 时出现问题

我正在按照此文档安装golangprotobuf在ubuntu14.04上为goversiongo1.6linux/amd64.但它没有安装protoc。我收到未安装protoc的错误。另外,我在路径环境变量中有$GOROOT/bin。 最佳答案 错误信息我很清楚,你必须先安装protoc工具,它在文档中指定:InstallthestandardC++implementationofprotocolbuffersfromhttps://developers.google.com/protocol-buffers/另外,报错信息也是这

bash - GOLANG 检查mongodb是否正在运行

我正在编写一个GO脚本来检查Mongo服务器是否正在运行。我的代码是,import"bytes"import"os/exec"import"fmt"funcmain(){cmd:=exec.Command("ps","-ef","|","grep","mongod","|","grep","-v","grep","|","wc","-l","|","tr","-d","'","'")fmt.Println(cmd)varoutbytes.Buffervarstderrbytes.Buffercmd.Stdout=&outcmd.Stderr=&stderrerr:=cmd.Run()i

bash - Go 和 MongoDB 连接不适用于紧急日志 "no reachable server"

我正在使用mGo作为我的GoWebApp到另一个MongoDB系统的驱动程序。所以我没有在同一个系统上运行Mongo。(URL不是本地主机)。但是,我收到“panic:没有可访问的服务器”错误。这是Go服务器启动时运行的测试函数:dialInfo,err0:=mgo.ParseURL("mongodb://1234MY456IP:27017,27018")iferr0!=nil{panic(err0)}dialInfo.Direct=truedialInfo.FailFast=truesession,err:=mgo.DialWithInfo(dialInfo)iferr!=nil{p