golang 如何编译同目录下多个main文件?

多个go 文件在相同目录编译时候会报错,

可将文件放在不同的package下,结构如下:

buidtest/
├── a
│   └── a.go
└── b
└── b.go

b.go

package main

import "fmt"

func main()  {
fmt.Println("b ....")
}

a.go

package main

import "fmt"

func main()  {
fmt.Println("a ....")
}

可采用如下方式编译安装:

go install ./...

此时执行,a,b

localhost:buidtest hao$ a
a ....
localhost:buidtest hao$ b
b ....

可以看到执行后将自动编译安装到项目到$GOPATH/bin 目录下;

您的赞赏是对我最大的支持

https://ieftimov.com/golang-package-multiple-binaries

go build Multiple main.go file的更多相关文章

  1. Warning: Multiple build commands for output file /xxx

    xcode中 有时候会报一个警告: [WARN]Warning: Multiple build commands for output file /xxx 要解决这个问题很简单: 1.选择你的工程 2 ...

  2. multiple build commands for output file

    在项目中  我们经常会碰到图片这方面的警告  虽然不影响运行 但是警告太多了也不是很好  其中 图片方面遇到的警告以下面的警告偏多:multiple build commands for output ...

  3. ld can't link with a main executable file for architecture armv7

    在iPhone 6 Plus上跑的时候遇到了这么一个错误:ld can't link with a main executable file for architecture armv7,然后就各种改 ...

  4. Error: Cannot open main configuration file '//start' for reading! 解决办法

    当执行service nagios start启动nagios时,报错:Error: Cannot open main configuration file '//start' for reading ...

  5. Mac OS build caffe2 Error:This file was generated by an older version of protoc which is

    问题所在 我们可以发现这个错误跟protobuf的版本有关,因此我们可以执行script/diagnose_protobuf.py 我们可以看到,pip install protobuf 和 brew ...

  6. [Functional Programming] mapReduce over Async operations with first success prediction (fromNode, alt, mapReduce, maybeToAsync)

    Let's say we are going to read some files, return the first file which pass the prediction method, t ...

  7. gin框架使用Air实时加载

    Air实时加载 本章我们要介绍一个神器--Air能够实时监听项目的代码文件,在代码发生变更之后自动重新编译并执行,大大提高gin框架项目的开发效率. 1.1.1. 为什么需要实时加载? 之前使用Pyt ...

  8. Visual Studio - File Properties (Build Action, Copy to Output Directory)

    Ref: MSDN (https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/0c6xyb ...

  9. Gradle Goodness: Changing Name of Default Build File

    Gradle uses the name build.gradle as the default name for a build file. If we write our build code i ...

随机推荐

  1. 怎样关掉 ubuntu 中的 System Program Problem Detected 提示框

    怎样关掉 ubuntu 中的 System Program Problem Detected 提示框 方法如下:sudo gedit /etc/default/apport  打开该文件如下:# se ...

  2. const & define & inline

    0x01  const & define区别 宏定义#define发生在预编译期,而const,enum定义的常量发生在编译期,两者的重要差别在于编译期里的变量是进符号表的,而预编译期的宏是简 ...

  3. MAC开发配置--Node和Npm

    前往Node官网下载最新的长期支持版本Node https://nodejs.org/zh-cn/download/   默认安装目录为:     •    Node.js v10.14.2 to / ...

  4. jmeter中添加压力机

    在压测的时候,可能并发比较大,一台机子已经启动不了那么多并发了,这个时候就是有多台机子一起来并发,就要添加压力机 如何添加压力机呢: 1.其他电脑上也安装了jmeter,和其他电脑都能ping通当前电 ...

  5. ylz外网连接ESB流程

    先在指定目录下写Controller,在目录下com.ylzinfo.controller.zhizhi package com.ylzinfo.controller.zhizhi; import j ...

  6. ios手动添加数组字典(NSMutableDictionary)

    @property (nonatomic,strong) NSArray *imageData;//定义一个数组 -(NSArray *)imageDate { if(_imageDate==nil) ...

  7. Jmeter监听tomcat

    配置cd /usr/local/tomcat/conf/tomcat-users.xml

  8. Python 数据结构--排序

      各种排序的时间复杂度和空间复杂度   以下 冒泡排序,选择排序,插入排序,合并排序,快速排序,希尔排序   1 冒泡排序(Bubble Sort) 冒泡排序(Bubble Sort)是一种简单的排 ...

  9. git 服务器安装流程

    参考:https://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E5%9C%A8%E6%9C% ...

  10. 使用 TortoiseSVN 创建 svn branch

    1.使用TortoiseSVN->Repo-browser进入仓库. 2.选择需要创建分支的文件->Copy to 添加分支路径后,点击ok Rename:trunk路径 格式:https ...