7 ms·
I love Go, used it a lot for over 3 years. I love the simplicity, directness, the inline structs, but I still cannot get out of the package management mess. I c
by CSDude 8y ago
I love Go, used it a lot for over 3 years. I love the simplicity, directness, the inline structs, but I still cannot get out of the package management mess. I can even tolerate `if err != nil, return err` and do not care enoguh of generics, but I hope Go modules and Go 2 would fix, over the time, it has really become a love-hate relationship for me. My daily driver at work is Java and some Python, I really miss the tooling (of course, not runtime classnotfound errors) and maturity. Not ignoring the success of projects with Go, such a big one as Kubernetes, I think it is a whole different aspect, but Go started to tear me out through the years, and it is hard to defend it.
- shazow 8y agoCan you expand on "I still cannot get out of the package management mess"? I've used the community dep project for a while, which was okay. I switched to the GO111MODULE experiment and it's more than okay.
- CSDude 8y agoTry adding a dependency to a big project like client-go or Docker client, it always gets messy for me.
- the_clarence 8y agoThere is no better way to do errors imo, unless you're going the erlang way of "let it fail". Errors can be passed to the caller the same way exceptions are, and it becomes an endless pursuit of where the error is actually being handled (if at all). I agree that some syntax sugar helps, see Rust, but it doesn't completely fixes the problem.
- nvarsj 8y agoIt's baffling though that the compiler doesn't at least warn when you forget to check the err. So many edge cases with that (especially due to `:=` vs `=` if reassigning a prior err).
- AlexCoventry 8y agoTry gometalinter. https://stackoverflow.com/questions/43898074/is-there-a-way-to-find-not-handled-errors-in-go-code https://stackoverflow.com/questions/43898074/is-there-a-way-...
- thegeekpirate 8y agoSpecifically (if wanted standalone) https://github.com/kisielk/errcheck https://github.com/kisielk/errcheck
- AlexCoventry 8y agoPersonally, I like my linter output in the style of a furious fruit salad, so I go for the kitchen sink.
- networkimprov 8y agoBut there are good ideas on how to do errors better... See Go2 Error Handling feedback: https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback And possible requirements for Go2 errors: https://gist.github.com/networkimprov/961c9caa2631ad3b95413f7d44a2c98a https://gist.github.com/networkimprov/961c9caa2631ad3b95413f...
- deleted 8y ago[deleted]
- tigershark 8y agoExhaustive pattern matching combined with ADT seems way better to me compared to the go error handling where it is pretty much guaranteed that you will shoot your own foot forgetting to handle some errors...
- weberc2 8y agoI agree this would be an improvement, but Go’s solution seems to work pretty well.
- pmoriarty 8y agoI have no love of Go nor of Java, but Python's packaging is a nightmarish tower of babel built upon a mountain of spaghetti. There are so many incompatible, NIH wannabe solutions to packaging in Python. Recent tools like pipenv have made things easier from the user standpoint, but if you dare to look at how the sausage is made it's still an absolute mess. Even if newer packaging tools are better, there are still tens of thousands of packages that use the older, nonstandard, even messier solutions.
- virmundi 8y agoHow do you keep track of dirty writes on structs? I want to only persist if the struct was actually changed. I could add getters setters, but a lot of the Go community seems to say I’m stupid for wanting to do that. I could track externally from the strict, but that seems backwards.
- weberc2 8y agoCan you elaborate for someone who doesn't know what "keeping track of dirty writes on structs" is for?
- randomdata 8y agoHe mentions persistence. Probably for use in an ORM-like fashion, where only the table columns that have changed are to be updated.
- PavlovsCat 8y agohttps://en.wikipedia.org/wiki/Persistence_(computer_science)#Dirty_writes https://en.wikipedia.org/wiki/Persistence_(computer_science)... I first heard of that in context of writing to the screen, actually, when you don't want to redraw all the things every frame, or simply can't afford to, and only draw the things that have changed (i.e. are "dirty"). So if you were to keep track of the old position of an object, you might redraw the area of background where that object was, and then just draw the object at the new position, instead of drawing the background for the whole screen, and then the object. Browsers are also kinda heavy on this when it comes to both layout and drawing. E.g. when the content of a div with fixed size changes, you only have to layout and draw the text in the div -- but if the size isn't fixed, you might relayout and redraw everything on the page that follows the div, but might not need to touch anything that comes before it. I'm sure it's incredibly complex, but still much faster than not doing it.
- virmundi 8y agoSure. I have a Profile. Let's say I load it from the database and make a change. I want to know if I need to save the profile. This is particularly important when using optimistic locking, a.k.a. resource versioning. My profile has a version number, like an ETag. I only want to update if there is a real change, and updating increases that revision number with every persist. Here's a scenario. A woman gets married. Her last name changes. She updates the profile from Smith to Jones. The last name is now dirty. The code that save the object can say, "Are you dirty?" The struct says, "Yup". Saving code says, "Right! In you go." On the other side, the bit gets flipped back to false (it's cleaned). At the end, the revision updates by one and goes back to the client. Another scenario. A user opens the edit profile box, doesn't change anything, but hits save. Without a dirty check, the object, which hasn't fundamentally change, gets saved with a new revision number. Now what is all this about the revision number? I don't want to allow changes to a profile whose revision number is greater than the revision number my client passes. Let's say the Profile has revision 5. The client, which has been disconnected for a bit, says, "Update the profile, at revision 2, with all this new great data." The system needs to reject that update. The client needs to tell the user, "Sorry. That didn't work. Here's all this new data." If the client is especially Canadian, it will also say, "Oh, by the way we've saved your data, would you like us to copy it over the new data". I've never seen Canadian code, and mine is especially Floridian, but it could happen like that. All of this is fairly easy in OO languages, which Go is not. It's actually easy in Go too if you use -ters and Setters (Go doesn't like GetFirstName(), but is okay with FirstName()). If I use functions attached to structs, easy. Just curious how other feel about this.
- 0x8BADF00D 8y ago> I love Go, used it a lot for over 3 years. I love the simplicity, directness, the inline structs, but I still cannot get out of the package management mess. The problem is the package managers available are fragmented and fundamentally incompatible. You have dep which is the official “experiment” and 10 others that share no compatibility whatsoever. Until there is either an official package manager or at least a standardization of the package format, you will run into these issues.
- mseepgood 8y agoI think you missed the last 6 months of development regarding Go dependency management. It's even mentioned in the blog post: "Last spring, we published a draft design for Go modules, which provide an integrated mechanism for versioning and package distribution. The most recent Go release, Go 1.11, included preliminary support for modules."
- shakna 8y agoSo there's ten incompatible package managers and one incomplete one. The situation will improve in future, but isn't there yet for all use cases.
- Zach_the_Lizard 8y agoI think go modules are still experimental, and thus many companies and projects have not yet converted. This has been my experience anyways; I'm still using dep at work. Because go modules came later, it will take a while for the community to convert, and there will still be dark corners running on Glide for probably another year or two (or longer).
- weberc2 8y agoThey’re official in version 1.11.
- Zach_the_Lizard 8y ago
- atombender 8y agoWe've transitioned entirely to Go modules. It's been largely painless at the codebase level. Being able to ditch GOPATH is fantastic. It helps that "go mod init" includes automatic migration from Dep. So far we haven't run into any serious bugs; compared to Dep (and Glide before it), "go mod" just works. However, the toolchain is lagging [1], sometimes in quite serious ways. Pretty much every third-party tool that reads Go source code — linters, code generators and so on — uses an unofficial, largely undocumented package called golang.org/x/tools/go/loader to parse Go code into AST structures. This package has not been updated to understand Go modules, and so it fails, and it has been abandoned in favour of a new, also largely undocumented library, golang.org/x/tools/go/packages, that works completely differently. There's a tracking issue [1] that discusses the progress of converting these tools. There's no document that describes how to migrate. It's annoying because we've come to rely on some, such as Mockery and go-sumtype, that still don't work with Go 1.11. In both cases the authors seem to have abandoned the projects, and updating the code isn't always so trivial. [1] https://github.com/golang/go/issues/24661 https://github.com/golang/go/issues/24661
- xiaq 8y agoI don't think you really mean golang.org/x/tools/go/loader or golang.org/x/tools/go/packages are literally undocumented; simply pasting the URL gives you pretty detailed godoc for both packages. Rather, there is no official "how to load Go packages guide" pointing to those packages, and tool developers probably discovered those only by reading other source code. FWIW, the .../loader package is explicitly documented as experimental. The .../packages has a deadline of 1 Dec 2018 for breaking changes (both info found in their respective godoc)
- agnivade 8y agoThe tools team is still working on go/packages. It is bound to get better. Given that modules support is still officially experimental, there are bound to be rough edges. But by 1.12, I think we will have a solid modules story.