Are Go modules really usable today given third party "incompatible" modules? - go

I am new to Go and trying to create my first program. Following the various getting started & tutorials I create a new module, which for my purpose needs to have a dependency on this module:
github.com/timescale/promscale#0.6.2
My problem is that the module has dependencies that have not "properly adopted" the semantic versioning approach.
go list -e -m all
...
k8s.io/client-go v12.0.0+incompatible
...
reports 37 such modules... so contacting the module author to have them adopt SIV, as I have seen suggested, will not be an option.
Am I missing something, or should I simply completely give up on using modules for this new project?

Are Go modules really usable today given third party "incompatible" modules?
Yes.
Am I missing something
Maybe: This "+incompabtible" is not a sign of failure.
or should I simply completely give up on using modules for this new project?
No, of course not.

Thanks for the answers and comments, it seems that:
New project should use modules, +incompatible dependencies will come up but that is fine
This FAQ entry has it right, just read the first 2 lines and keep "Additional Details" for a rainy day
go list -m all won't behave as described in all the tutorials if +incompatible dependencies exist, it will choke on the first incompatible module instead.
go list -m -e all seems to work as expected.
If you are using Goland, using GOFLAGS=-e seems to make dependency resolution work despite +incompatible modules. This may well have side effects that I am not aware of.

Related

Where to find golang modules?

I am from node.js ecosystem.
Golang has released its module system finally and I have read some articles about it:
https://blog.golang.org/using-go-modules
https://github.com/golang/go/wiki/Modules
But, after that, I still didn't find a place like npmjs.com where I can find available go modules.
There is no central repository yet, but note that the module support is still experimental in Go 1.12. It will be enabled by default in Go 1.13 (scheduled for August 2019).
Check out The Go Blog: Go Modules in 2019.
For publicly-available modules, we intend to run a service we call a notary that follows the module index log, downloads new modules, and cryptographically signs statements of the form “module M at version V has file tree hash H.” The notary service will publish all these notarized hashes in a queryable, Certificate Transparency-style tamper-proof log, so that anyone can verify that the notary is behaving correctly. This log will serve as a public, global go.sum file that go get can use to authenticate modules when adding or updating dependencies.
We are aiming to have the go command check notarized hashes for publicly-available modules not already in go.sum starting in Go 1.13.
and
Module Discovery
Finally, we mentioned earlier that the module index will make it easier to build sites like godoc.org. Part of our work in 2019 will be a major revamp of godoc.org to make it more useful for developers who need to discover available modules and then decide whether to rely on a given module or not.
Big Picture
This diagram shows how module source code moves through the design in this post.
There is no central repository for Go modules. As long as you follow the conventions for publishing Go packages (see PackagePublishing), the go tools will be able to fetch your package/module, no matter where you published it.
In order to discover what is already out there in the Go universe, a good starting point is Awesome Go, a curated list of awesome Go packages/modules.
https://search.gocenter.io can be used to search for Go modules, know more about popularity of a module version and even help module authors connect with their consumers. This is GA since end of January 2019 and globally available.
I had the same question. If you start off with the built-in packages (https://golang.org/pkg/), and you follow some non-obvious links, you eventually end up here:
https://pkg.go.dev/

Module does not cache/save in golang test/build process. How do you work around this?

In one of my projects, using go modules. It has started to continually do a search for a module every single time I do anything. I include lots of modules, but only one does this (see below). How do I work around this?
> go test -run TestUodate
go: finding github.com/mohae/deepcopy latest
PASS
ok example.com/example/stuff 0.698s
This symptom looks like the one in https://golang.org/issue/29773, which is fixed at head (but not in go1.13beta1 or earlier releases). Try it using a go command built from head, which you can obtain easily using the gotip tool.
If you're still seeing this using gotip, please open an issue by filling out the template at https://golang.org/issue/new.

Aurelia CLI and braintree-web

I am trying to use https://www.npmjs.com/package/braintree-web with Aurelia (using the aurelia-cli and RequireJS). I am stuck trying to get all the many dependencies to resolve.
To use 3rd party library in Aurelia the library must be defined in the aurelia.json file.
If I add "braintree-web" in that file then aurelia complains that "braintree-web" it requires the modules "american-express", "apple-pay" etc etc.
If I manually create the "american-express", "apple-pay" dependencies then each one also refers to "braintree-web/lib", and a bunch of other sub-directory dependencies.
In short I can't get the "braintree-web" module to load because I have to manually build all sub-dependencies and its too complex to get working.
As I state above, I am using requireJS, should these dependencies all resolve correctly?
Any ideas as to how I can get this working?
Thanks
If all dependencies is what you need, then with requirejs + aurelia-cli you'll have to declare all dependencies. There is an experimental version of the cli being developed which you can find here, where you won't have to declare any dependencies in aurelia.json anymore.
With webpack you also don't need to declare any dependencies by the way.
Do you really need everything though? The docs mention for example you could import just the client. Still looks like a whole heap of dependencies, but at least a lot less than importing the main index.js.
You could also just include their pre-bundled client which I believe is https://js.braintreegateway.com/web/3.32.1/js/client.min.js
On a side note, the person developing aforementioned experimental CLI is actually looking for people to test it with non-trivial apps. Me and several others have tried it with great results, so I can recommend you try it. If you could report back in the PR that would be really awesome.

Golang requirements.txt equivalent

Coming from a python/django world, it'd be great to have something like a requirements.txt equivalent for go/revel. How can I do this? I know I can just write a requirements.txt file and then do something like
cat requirements | xargs go get
But what if my requirements ALSO have requirements? The above command would attempt to "go get" them, and then they'd fail to build, since I don't have those requirements installed.
Is there something I'm missing?
The command go get does exactly what you need: It finds all dependencies and downloads and installs the missing ones. Focus on "all": go get really traverses your dependency graph.
Have a look at the documentation:
https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them
The Go documentation is really clean, short and well written. I would recommend always to have a look at the documentation first before making assumptions which are based on experience with other tools or tool-chains.
They also provide useful blog posts, https://blog.golang.org/using-go-modules
I just found that the kubernetes guys actually have created an overview page for themselves here.
Summary is this: Currently stable is Glide and the cool new toy is called dep

Any existing pure PHP "make" tools?

Let me elaborate on the question...
I have a custom CMS (built on codeigniter FTW) that includes many different types of modules.
Every time we have a new project come through the door, it is a variation and amalgamation of a few of the existing modules.
Sometimes a project comes through with requirements that are not satisfied by the existing modules, in that case I will write a new module...
All the modules are separated out in folders and the code is VC-ed using GIT. Every module has it's own Model, View, Controller, SQL and Javascript files. All the dependencies are also separated and folder-ed nicely...
The next step for me is to create some sort of installer script that will take me through the "scaffolding" process step by step, allowing me to choose from the existing modules. A glorified "makefile" if you may...
Rather than rolling my own, does anyone know of any such thing out in the wild.
I know of Apache ANT (java), what I need is something in pure PHP with very low or no dependencies...
I would like something as simple as running a git pull and then php make.php
Thanks.
The "Ant-like" alternative I am aware of in PHP land is phing it is written in PHP and it will allow you to perform several tasks for packaging, deploying and testing your web applications. The documentation is a great starting point if you want to hit the ground running.
It is can also be extended to define new tasks if needed (examples and explanations are provided in the documentation)
Reading through the doco it appears to be possible to install Phing without PEAR as documented here you would have to correctly setup the environment on each machine you wish to use Phing on. I can not confirm this method though as I use PEAR for all my installs.

Resources