如何通过命令行删除/ bin目录中的二进制文件?

德米特里(Dmitry S.):

go install$HOME/go/src/hello/进入目录的二进制文件中运行命令$HOME/go/bin,然后运行go clean,但是二进制文件不会删除。

如何通过命令行删除/ bin目录中的二进制文件?

输出go env

GOARCH="amd64"
GOBIN="/home/stavanger/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/stavanger/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build610113564=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

.zshrc

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
peterSO:

-i标志使clean删除相应的已安装存档或二进制文件(['go build'或]'go install'将创建的内容)。

尝试go clean -i标志?


$ go help clean
usage: go clean [-i] [-r] [-n] [-x] [-cache] [-testcache] [build flags] [packages]

Clean removes object files from package source directories.
The go command builds most objects in a temporary directory,
so go clean is mainly concerned with object files left by other
tools or by manual invocations of go build.

Specifically, clean removes the following files from each of the
source directories corresponding to the import paths:

    _obj/            old object directory, left from Makefiles
    _test/           old test directory, left from Makefiles
    _testmain.go     old gotest file, left from Makefiles
    test.out         old test log, left from Makefiles
    build.out        old test log, left from Makefiles
    *.[568ao]        object files, left from Makefiles

    DIR(.exe)        from go build
    DIR.test(.exe)   from go test -c
    MAINFILE(.exe)   from go build MAINFILE.go
    *.so             from SWIG

In the list, DIR represents the final path element of the
directory, and MAINFILE is the base name of any Go source
file in the directory that is not included when building
the package.

The -i flag causes clean to remove the corresponding installed
archive or binary (what 'go install' would create).

The -n flag causes clean to print the remove commands it would execute,
but not run them.

The -r flag causes clean to be applied recursively to all the
dependencies of the packages named by the import paths.

The -x flag causes clean to print remove commands as it executes them.

The -cache flag causes clean to remove the entire go build cache.

The -testcache flag causes clean to expire all test results in the
go build cache.

For more about build flags, see 'go help build'.

For more about specifying packages, see 'go help packages'.
$

命令去

删除目标文件

用法:

go clean [-i] [-r] [-n] [-x] [build flags] [packages]

清除将从软件包源目录中删除目标文件。go命令可在临时目录中构建大多数对象,因此go clean主要涉及其他工具或go build的手动调用留下的对象文件。

具体来说,clean从与导入路径相对应的每个源目录中删除以下文件:

_obj/            old object directory, left from Makefiles
_test/           old test directory, left from Makefiles
_testmain.go     old gotest file, left from Makefiles
test.out         old test log, left from Makefiles
build.out        old test log, left from Makefiles
*.[568ao]        object files, left from Makefiles

DIR(.exe)        from go build
DIR.test(.exe)   from go test -c
MAINFILE(.exe)   from go build MAINFILE.go
*.so             from SWIG

在列表中,DIR表示目录的最终路径元素,而MAINFILE是构建软件包时不包含的目录中任何Go源文件的基本名称。

-i标志使clean删除相应的已安装归档文件或二进制文件(“ go install”将创建什么)。

-n标志使clean打印将执行的删除命令,但不运行它们。

-r标志使clean递归地应用到由导入路径命名的软件包的所有依赖项。

-x标志使clean在执行删除命令时打印它们。

有关构建标志的更多信息,请参见“ go help build”。

有关指定软件包的更多信息,请参见“转到帮助软件包”。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何通过命令行从公共 github 存储库下载二进制文件?

如何通过命令行删除特定文件?

如何获取ASP.NET MVC发布以通过本机二进制文件复制到bin目录

npm已安装的二进制文件在命令行中不可用

使用标准linux命令行工具修改二进制文件中的字节

连接Windows中的二进制文件(无命令行)

如何在Linux容器内的/ bin中替换二进制文件

如何执行存在于不同目录中的二进制文件?

如何从Vim的Netrw目录列表中的文本/二进制文件视图导航回去?

如何欺骗bash认为我从二进制文件所在的目录中运行了脚本?

如何在 tmux-sidebar 目录树中隐藏二进制文件?

如何使用pyinstaller在与exe相同的目录中添加二进制数据文件?

如何从命令行获取二进制文件权限?

二进制文件如何“二进制”?

如何通过命令行提交文件?

如何从git中删除二进制文件

如何从二进制文件中删除HomeKit API

如何从.py文件中获取二进制文件

通过在我的PATH中放入二进制文件,通过MAC命令行安装程序

通过分层$ PATH在当前目录的父目录中递归查找二进制文件

C ++:从二进制文件中删除记录

二进制文件已从 iTunesConnect 的活动中删除

从二进制文件中删除未使用的函数

在SFTP中通过二进制模式传输文件

如何通过Selenium服务器独立命令行指定Chrome二进制位置?

如何在Julia中读取二进制文件?

如何在Android中编辑二进制文件?

如何在Go中读取二进制文件

如何grep二进制文件中的行号?