Go安装不会创建任何bin文件 [英] Go install doesn't create any bin file

查看:469
本文介绍了Go安装不会创建任何bin文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件夹结构是正确的,我可以从包文件夹内以及系统中的任何位置运行 go install ,将包(文件夹)名称添加到 install

My folder structure is correct, i can both run go install from inside the package folder and from anywhere in the system, adding the package (folder) name after install.

例如,我的工作空间如下:

For example, my workspace is the following:

Go\
  bin\
  pkg\
  src\
    name\
      file.go

然后,如果我运行

cd %GOPATH%\src\name
go install

go install name

没有错误产生,我的工作空间变成以下内容:

no errors are generated and my workspace becomes the following

Go\
  bin\
  pkg\
    windows_amd64\ <-- new!
      name.a       <-- new!
  src\
    name\
      file.go

包文件正确创建,但bin文件不是。

Package files are correctly created, but bin files aren't.

My go env如下:

My go env is the following:

C:\Users\...>go env
set GOARCH=amd64
set GOBIN=C:\Users\myname\Documents\Go\bin
set GOCHAR=6
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\myname\Documents\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

为什么会出现这种情况?我错过了什么,做错了什么?我想要bin文件与包文件一起创建。

Why is this the case? Am i missing something, doing something wrong? I want bin files to be created along with package files.

推荐答案

原因可能是文件。 go 不在 package main中

请参阅示例您的第一个程序

如果是这样,那会在 bin

文章 go build命令如何工作?不提:

The article "How does the go build command work ?" does mention:


Go命令是名称为 main 的包。

编译主包或命令就像其他软件包一样,但是接下来要经过几个额外的步骤才能链接到最终的可执行文件中。

A Go command is a package who’s name is main.
Main packages, or commands, are compiled just like other packages, but then undergo several additional steps to be linked into final executable.

这篇关于Go安装不会创建任何bin文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆