dqoys62082 2018-02-15 15:52
浏览 158
已采纳

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

I run command go install in $HOME/go/src/hello/ that binary file get in catalog $HOME/go/bin, then run go clean, but binary file don't remove.

How one can I delete a binary file in the /bin directory via the command line?

Output 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
  • 写回答

1条回答 默认 最新

  • dongyan1993 2018-02-15 15:57
    关注

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

    Try the go clean -i flag?


    $ 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'.
    $
    

    Command go

    Remove object files

    Usage:

    go clean [-i] [-r] [-n] [-x] [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.

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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测