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 ...
随机推荐
- CSS(三)--自定义标签
HTML代码 <body> <ul> <li>1</li> <li>2</li> </ul> </body&g ...
- minifilter
暑假刚开始的时候,参照<寒江独钓>这本书,用VS2015写过的一个minifilter的框架,今天在博客上分享出来. VS2015已经有了minifilter的框架模板,直接生成了mini ...
- Activity中通过标签获取当前Fragment
初始化完成之后才有数据,否则获取不到 String tag = "android:switcher:"+viewPager.getId()+":"+viewPa ...
- SpringMVC学习三
实现有点用处的增删改查,并利用了AJAX(javascript)动态修改,还有json的返回读取,以及文件上传和下载. 配置基础Employee类以及Dao类 package com.springmv ...
- LVS原理详解(3种工作方式8种调度算法)
一.集群简介 什么是集群 计算机集群简称集群是一种计算机系统,它通过一组松散集成的计算机软件和/或硬件连接起来高度紧密地协作完成计算工作.在某种意义上,他们可以被看作是一台计算机.集群系统中的单个计算 ...
- 多路复用 阻塞/非阻塞IO模型 网络IO两个阶段
1.网络IO的两个阶段 waitdata copydata send 先经历:copydata阶段 recv 先经历:waitdata阶段 再经历 copydata阶段 2.阻塞的IO模型 之前写的都 ...
- 在线播放Video/PDF/JPG
Label1.Text = Play(url, , ); public string Play(string url, int width, int height) { string strTmp = ...
- Python 操作系统介绍 进程的创建
背景知识 顾名思义,进程即正在执行的一个过程.进程是对正在运行程序的一个抽象. 进程的概念起源于操作系统,是操作系统最核心的概念,也是操作系统提供的最古老也是最重要的抽象概念之一.操作系统的其他所有内 ...
- robotframework·WEB项目
date:2018527 day11 一.项目分层 1.测试数据(配置变量,如网址.用户名.密码等) 2.关键字(关键字封装,要调用直接使用关键字名即可,输入内容.点击元素.滚动滑动条等等) 3.测试 ...
- 小程序 textarea
1.小程序中textarea不能在scroll-view.swiper.picker-view等等里面运用. 2.不在fixed布局的页面中,placeholder也会随着页面滚动,解决方法:顶级父元 ...