Parquery / gocontracts

A tool for design-by-contract in Go
MIT License
111 stars 7 forks source link

precommit script #23

Closed KantarBruceAdams closed 5 years ago

KantarBruceAdams commented 5 years ago

Hi, I notice the precommit script is written in python. I'm not sure that is a good fit with the go ecosystem. Couldn't you do the same directly in go?

Regards,

Bruce.

mristin commented 5 years ago

Hi @KantarBruceAdams We opted for ease of implementation instead of language purity.

I first tried to implement the precommit script as a go script (to be run with go run precommit.go), but then realized it had all sorts of issues (getting the current working directory was not easy since it compiled and ran from a temporary directory, glob implementation in Go is nearly not as elegant as in Python etc.).

Is there any reason why you would strongly prefer a go script instead of a python one given the simplicity of precommit.py?

KantarBruceAdams commented 5 years ago

It was just a thought. Its simply language purity. Individual projects should have as few different dependencies as possible.

If someone wants to hack on this project do they need to install python? do they need to learn it? When should they run this script?

mristin commented 5 years ago

The main place that the precommit checks are executed is on travis CI (see .travis.yml); the developer is actually only expected to satisfy the checks, but not to check them manually.

Could you show me in a snippet how you would write the precommit checks in Go or do you know another project that defines them in a separate file?

I looked a bit around, but couldn't find anything really usable. Most people only defined the checks in .travis.yml.

KantarBruceAdams commented 5 years ago

You have me there. I only just started learning go. My python is better and I've never used Travis (I use Jenkins).

mristin commented 5 years ago

:) would you mind if I close the issue? Of course, you can re-open it when you find a better way than python (I looked around a bit more today, but found no good example).

KantarBruceAdams commented 5 years ago

Sure.