在现有的 Golang 应用程序中安装 Soda CLI。

huangapple go评论88阅读模式
英文:

Installing soda cli in existing app golang

问题

描述

在现有应用程序中安装soda cli时出现问题。我按照文档下载了cli。
https://gobuffalo.io/en/docs/db/toolbox

复现步骤

$ go get github.com/gobuffalo/pop/...
$ go install github.com/gobuffalo/pop/soda

期望的行为

当我输入soda -v时,它应该显示soda的版本号。

实际的行为

soda: 命令未找到

信息

操作系统:ubuntu 21

英文:

Description

Issue while installing soda cli in existing app
I downloaded the cli like the documentation
https://gobuffalo.io/en/docs/db/toolbox

Steps to Reproduce the Problem

$ go get github.com/gobuffalo/pop/...
$ go install github.com/gobuffalo/pop/soda

Expected Behavior

when i write soda -v
it must show soda version

Actual Behavior

soda: command not found

Info

OS: ubuntu 21

答案1

得分: 2

问题很可能是soda二进制文件安装的路径不在您的PATH系统变量中。

要知道您的Go二进制文件安装在哪里,请运行:

go env | grep GOPATH

这将打印出:

GOPATH="/path/to/go"

然后,您需要将/path/to/go/bin添加到您的环境变量中,可以通过.bashrc.zshrc.profile或其他需要将其添加到环境中的文件,添加以下行:

export PATH="$PATH:/path/to/go/bin"

您可以使用一条命令完成所有操作:

echo "export PATH=\"$PATH:${$(go env | grep GOPATH | cut -d '=' -f2):1:-1}/bin\"" >> .bashrc
英文:

The problem is very probably that the path where the soda binary gets installed is not in your PATH system variable.

To know where your go binaries are installed, run:

go env | grep GOPATH

This will print:

GOPATH="/path/to/go"

Then you need to add /path/to/go/bin in your environment, through your .bashrc, .zshrc, .profile or whatever you need to have it in your environment, adding the line:

export PATH="$PATH:/path/to/go/bin"

You can do all of this in one single command:

echo "export PATH=\"$PATH:${$(go env | grep GOPATH | cut -d '=' -f2):1:-1}/bin\"" >> .bashrc

答案2

得分: 0

如果在go/bin目录下安装了soda,

只需为soda添加一个别名

打开终端并输入以下命令

alias soda="~/go/bin/soda"

要创建永久别名

sudo nano ~/.bashrc

在文件末尾写入别名

alias soda="~/go/bin/soda"
英文:

If soda is installed inside go/bin

Just add an alias for soda

Open your terminal and write this command

alias soda="~/go/bin/soda"

To write permanent alias

sudo nano ~/.bashrc

And in the end of file write the alias

alias soda="~/go/bin/soda"

huangapple
  • 本文由 发表于 2022年1月29日 19:24:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/70904827.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定