pebbe / zmq4

A Go interface to ZeroMQ version 4
BSD 2-Clause "Simplified" License
1.17k stars 166 forks source link

examples submodule #173

Closed CrimsonVoid closed 3 years ago

CrimsonVoid commented 3 years ago

Make examples and examples_security submodules, removing the only external dependency. I wasn't sure about moving examples_security to examples/security, but I can update the PR if you think that would make more sense.

This PR depends on an unreleased version zmq4 1.3.0

Unfortunately it seems the best way to convert a subpackage into a module is to depend on a future version where that subpackage doesn't exist; the naïve solution leads to build failures. You can add replace github.com/pebbe/zmq4 v1.3.0 => ../ to go.mod if you want to test the changes.

See https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository

pebbe commented 3 years ago

Thank for this. I looked at what you did, and decided to do it a little differently.

The directory examples_security doesn't need its own go.mod because it doesn't have external dependencies. It can use the go.mod in the parent direcory.

For examples/go.mod I used a replace, so as to not depend on a particular release. This means you can't do a go get github.com/pebbe/zmq4/examples/... but you couldn't do that anyway, because there are sources for different programs in the same directory. To make this possible, I would need to move each program to its own subdirectory, but I don't think you would want to run go get or go install on all examples anyway, because you would end up with 81 programs in your general bin directory.

CrimsonVoid commented 3 years ago

ty, I'll go ahead and close this.

Also, you might want to look into replacing github.com/pborman/uuid with github.com/google/uuid since it's just a thin wrapper around google's library. It's not a drop-in replacement, but the few errors I got when building examples had pretty simple fixes.