I am trying to create a debian package with 3 golang executables that share the same golang library. My directory contains the following files:
- rtd_dsp.go an executable that shows streaming measurements on the commandline
- rtd_web.go an executable that shows last measurement via webserver
- rtd_influxdb.go an executable that stores streaming measurements into a database
- dmn.go library code including listener for multiple measurement streams
The executables can be easily created as follows:
- go build rtd_dsp.go dmn.go
- go build rtd_web.go dmn.go
- go build rtd_influxdb.go dmn.go
I found the debian package dh-golang for creating debian packages, and am trying to get that working. However, it seems not as simple as advertised, it complains about a number of things after creating a debian folder with the required changelog, control, copyright and rules, source/target files and running
dpkg-buildpackage -us -uc -d using dh-golang 1.48 on Ubuntu 20.04.2 (with golang-1.16):
- that it cannot find the external packages, while they are available for grabs in $(GOMODCACHE)=$(HOME)/go/pkg/mod, in my view it can either get them itself or re-use the available ones. As an experiment I modified golang.pm to set the GOPATH to the $(GOMODCACHE).
- that it cannot find any Go files, while are just available in the created _build/src/sst-goflow directory.
- I expected an error that the executable go files each implement the same handleMessage call (as a simple
go installindicates), while I would want it to create separate executables
Is there an easier way to create a debian package with golang executables? And/or are the above problems easy to solve?