-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Weird" code conventions #13
Comments
Most
|
I hope you realize that there is still a lot of work to be done, things that are "unused" may only be "not used yet". Things that are only used in one place may be used elsewhere later on. As for the logging, having our own logging is a good thing. yes, go's stdlib logging library does "work", but I have a feeling we will get into some interesting situations where having our own logging wrappers will greatly behoove us. |
@whyrusleeping Of course, this just started but things tend to be delayed, sometimes forgot. It's better to have a clean codebase from the start and Go makes it easy (go vet, golint and goconvey do help a lot too). As for logging, log will get you a long way, then there's https://github.com/golang/glog. |
@toqueteos thanks for going through and providing constructive feedback. I disagree with many of the comments. Below is my reasoning. However, I want to express a few high level points:
This is a strong disagreement with idiomatic Go. Imports should be explicit. The package name should be absolutely clear. There is ambiguity when imports like this happen: import (
"github.com/jbenet/go-multihash"
) So as I see it, all package imports should be explicit. (stdlib gets a free ride because I'm not pedantic, rules always break down somewhere)
IMO, visual cleanliness, while important, is trumped by logical cleanliness (imports being explicit). The sorting, placement, etc., I don't care about, sure!
We'll have a LOT of random crap as we go.
For now. This will change, and will only change in one place instead of N (as @whyrusleeping pointed out).
Great point, maybe we should switch to using
Not true. I use them a lot. I usually remove most debug statements, but some we'll want to start keeping.
Evaluating the print still needs to happen. This might be really bad if printing out entire data structures, which I sometimes do. Hence these functions.
Cyclic dependency.
Yeah probably right. Feel free to move it. It might get used elsewhere, and then we can move it back. This, of course, is unnecessary work at this time.
Looks interesting! Might be overkill atm, but probably the right way to go later, thanks!! @whyrusleeping has precisely the right perspective here:
Thanks for the effort + feedback, @toqueteos! Very much appreciated. Just please bear in mind my perspective here, and priorities. The goal is to move fast until a stable first implementation exists. By the way, i'd like to point out that lots of git is written in shell scripts. This makes me cringe. But I totally get why they did that. It made it much faster for them to iterate, etc. likewise here, I'm not going to be a stickler for codebase style rules or implementations being precisely how i think they should work. Rather, the main concern is getting the API right, and working, robust implementation. Thanks!! :) |
You are welcome @jbenet! Your repo, your project, your rules but be aware that more Go style criticism will appear as time goes and ipfs gets more traction (which it deserves, lots of it). All of this was found while I was reading the code and checking the whitepaper, checking what is implemented and what not trying to understand how all the ideas fit together and even maybe implement some pieces myself. Just a quick reply to some of your answers:
I won't bitch anymore about conventions. |
Yep! Understood, and criticism is definitely welcome. I just won't always change my mind ;). And thanks!! :D
This is not always the case. If I go and create a new version that happens to change the package name I now have to rewrite code, not just update an import. This is IMO a failure in the go design.
The fact that the logical naming may or may not (but not always does or not) match the package import addresses reflects how bad of a design idea this was. And the fact that you can't fix to particular versions, e.g. import (
multihash "github.com/jbenet/go-multihash@deadbeef"
) (without making them accessible in directories at the endpoint) makes me sad.
Since you brought it up, I'll rant a little bit about this. :) This is so stupid. REQUIRING a change in the names that projects get in websites external to Go is simply absurd. Implementations in multiple languages happen. It is standard to prefix or suffix languages in the repo names to clarify. This shouldn't be a problem. And this is just one of many reasons. The Go team + community should:
Ah, but it will :). See https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-core/index.js Thanks! |
Oh will add that, Go team was smart and didn't force this at all. It's bad that it's idiomatic convention though. So, my imports are explicit. And once IPFS is up, versioned correctly. Soon, we'll have things like: import (
ipfs "/ipns/gopkg.io/ipfs/1.2.3"
mh "/ipns/gopkg.io/multihash/deadbeef1234567890"
ma "/ipfs/deadbeef1234567890/go-multiaddr"
) More at jbenet/random-ideas#19 |
Add protocol buffers for binary injection/joining
add experiment for p2p http proxy
add experiment for p2p http proxy
add experiment for p2p http proxy
add experiment for p2p http proxy
gx: update go-libp2p-routing
Things like this are weird for code reviewing.
Most of those named imports are useless (same name as package name) and unsorted.
gofmt will deal with import sorting, separating std from local package and other (non-std) packages would be the best way to go (it doesn't violate any code conventions and it's better for readers/reviewers).
The text was updated successfully, but these errors were encountered: