美文网首页
Go-Goland可执行文件生成

Go-Goland可执行文件生成

作者: EamonYi | 来源:发表于2019-10-04 12:28 被阅读0次

刚接触go语言,根据网上搜索的方法搭建好了环境,安装了IDE,今天卡在了可执行文件的生成上。下面描述下Goland生成可执行文件的配置情况。

环境情况

  • 2015-MBP
  • Goland-2019.2
# go env 
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/usr/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/usr/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/T/go-build445033478=/tmp/go-build -gno-record-gcc-switches -fno-common"

代码情况

# helloworld.go
package main

import (
    "fmt"
    "time"
)
import "./config"

func main()  {
    fmt.Printf(config.Content)
    time.Sleep(1000*1000*1000)
}

# config.go
package config

var Content="HELLO WORLD"

目录结构如下:

- helloworld
    - src
        - config
            - config.go
        - helloworld.go

截图见附件image.png

build配置

Run -> Edit Configuration -> Go Build -> go build helloworld.go -> Go tool arguments

-o ../bin/哈哈哈哈

Apply -> OK

生成可执行文件

src目录右键 -> Run -> go build src/

新的目录结构如下:

- helloworld
    - bin
        - 哈哈哈哈
    - src
        - config
            - config.go
        - helloworld.go

截图见附件

相关文章

网友评论

      本文标题:Go-Goland可执行文件生成

      本文链接:https://www.haomeiwen.com/subject/trftyctx.html