go build Multiple main.go file
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的更多相关文章
- Warning: Multiple build commands for output file /xxx
xcode中 有时候会报一个警告: [WARN]Warning: Multiple build commands for output file /xxx 要解决这个问题很简单: 1.选择你的工程 2 ...
- multiple build commands for output file
在项目中 我们经常会碰到图片这方面的警告 虽然不影响运行 但是警告太多了也不是很好 其中 图片方面遇到的警告以下面的警告偏多:multiple build commands for output ...
- 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,然后就各种改 ...
- Error: Cannot open main configuration file '//start' for reading! 解决办法
当执行service nagios start启动nagios时,报错:Error: Cannot open main configuration file '//start' for reading ...
- 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 ...
- [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 ...
- gin框架使用Air实时加载
Air实时加载 本章我们要介绍一个神器--Air能够实时监听项目的代码文件,在代码发生变更之后自动重新编译并执行,大大提高gin框架项目的开发效率. 1.1.1. 为什么需要实时加载? 之前使用Pyt ...
- 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 ...
- 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 ...
随机推荐
- 非递归实现二叉树的三种遍历操作,C++描述
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- MyEclipse复制js文件乱码
MyEclipse复制js文件乱码 右击js文件:
- Cracking The Coding Interview 5.5
#include <iostream> #include <vector> using namespace std; int getNum1(int N) { int num= ...
- js正则学习
一直对正则很纠结也很畏惧,以前感觉花时间理解一个个奇奇怪怪的符号,还不如直接百度谷歌之. 但知其然不知其所以然也是种痛苦,所以花了两天稍微学了一下,虽然没学很深入彻底,但也比之前进步不少,特此笔记. ...
- 04 复制删除行为IDA反汇编
(很久以前的学习记录,放到博客上来) (IDA5.0版的不知道为何反汇编进去每一行被截断的景象,惨不忍睹......明明是个正版的.只好回来用拷过来的破解版,依然有一些叽里呱啦的问题,懒得管了, ...
- <Flume><Source Code><Flume源码阅读笔记>
Overview source采集的日志首先会传入ChannelProcessor, 在其内首先会通过Interceptors进行过滤加工,然后通过ChannelSelector选择channel. ...
- <kafka><应用场景><Kafka VS Flume>
前言 最近在搭一个离线Hadoop + 实时SparkStreaming的日志处理系统,然后发现基本上网上的这种系统都集成了kafka. 自己对kafka有一点点的认识,之前看过官网文档,用过一次,就 ...
- L260
Innovative UK technology that can deliver drugs deep into the brain to treat neurological diseases, ...
- css 1) calc() 函数的使用. 2)box-sizing:border-box
calc() 是一个css 函数, 可以实现.计算 ---------------------------- 1. 每个div宽度是25%; 总共4个div. 同时 前三个div 有 border-r ...
- Vuejs 用$emit 与 $on 来进行兄弟组件之间的数据传输
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...