229 points · by pythonist · 9y ago · 136 comments
Finally. This is going to make it easier for newcomers to the Go ecosystem, since commands such as "go get" will now work out of the box.
Go has a list of locations to look for projects (packages) in ($GOPATH) and by default does not include the working directory. Unlike Python's sys.path, $GOPATH normally only contains a single value.
Python's behavior is similar to $PATH on Windows while Go's behavior is similar to $PATH on Unix.
There are pros and cons to each default value but either language can be overridden to have the other's behavior if you desire.
I personally quite like having a single unified $GOPATH for all of my source.
How? With Python I can release a package with code like `import foo from .` in it. This will not work in Go, a GOPATH package must import things from subdirectories via GOPATH. At least, this was the case the last time I checked.
This used to work okay-ish until Go 1.5. Then Go 1.6 introduced vendoring support (i.e. you put the code for the libraries you need into your own repo) which is very nice if it works, so I wanted to have it. But `go build` stubbornly refuses to look at vendored code when you are not in the exact correct location inside the GOPATH.
To preserve the familiar build semantics, I set up the GOPATH inside the repo. Roughly like this:
$ git clone https://github.com/foo/bar && cd bar
$ mkdir -p .gopath/src/github.com/foo
$ ln -sTf ../../../.. .gopath/src/github.com/foo/bar
$ GOPATH=$PWD/.gopath go build github.com/foo/bar
Of course, all that bullshit can be nicely tugged away in the Makefile. For example: https://github.com/sapcc/swift-drive-autopilot/blob/a3d5d02b...You can find this either hilarious or sad. I like the irony in using make(1) to patch up the deficiencies of a tool that was created decades after it.
You are trying to build Go in a way it wasn't designed for.
Go encourages absolute import paths (relative to $GOPATH) and solves a myriad of other language faults in this way. A good benefit is go-gettable projects, where all dependencies can be reached without a setup/configuration file (like setup.py, requirements.txt, and so on).
If you do not try to use Go like other language, your build should be something like:
$ GOPATH=$PWD/some/path go get github.com/foo/bar(I have no affiliation with gb)
In some ways this is similar to cargo which depends on existence of ~/.cargo
btw. you can manually invoke Go compiler and linker. A very simple example from some time ago can be found here: https://github.com/tumdum/go_build
This doesn't restrict you to using a special path or a particular mode of organizing. Rather, it leaves much of that problem to the user, for better or for worse. It's perfectly fine to write programs with GOPATH unset.
Now if they could figure out a way to get go get to work nicely with private repos out of the box without SSH config hacks that'd be great..
I worked on the YCM support for godef, we eventually had to fork the library and rewrite paths since there was no way of pinning to a version within YCM. Libraries written with github paths for `go get` do not play nice with living outside of gopath, and libraries written with relative paths don't work with go get (even though this is something that go could support)
ln -s PROJECT_SOURCE_FOLDER $GOPATH/src/
https://plus.google.com/u/0/+RobPikeTheHuman/posts/R58WgWwN9...
Oh, that's rich. This from the guy who designed a language where the case of a symbol's name determines the symbol's visibility.
I can't wait to start adding in the mutex contention to our tests, remove our custom graceful http shutdown library, compile 15% faster, start using context within our queries, write custom comparators [I needed this just last week! We had a type that already implemented the sort interface, but I needed to sort it by a different key in this one-off] for sorting, and have a much better time debugging JSON unmarshalling.
And those were just the big pieces I noticed that will be an immediate improvement!
On a side note, you always could.
Yes, with brand new sorter types for each different comparison. Knowing that Go had first-class functions from the beginning, it is actually quite surprising that a higher-order sort function didn't already exist.
Given the following literal:
<script type="text/javascript"> <div><%= something %></div> </script>
Go 1.8 will escape the EJS delimiter, breaking the template. I.e.:
<script type="text/javascript"> <div><%= something %></div> </script>
I selected EJS specifically because I wanted a templating library that didn't conflict with html/template's handlebars syntax. If you're in the same boat you'll want to find a template engine with non-html entity delimiters.
https://github.com/golang/go/issues/18569
I think your comment above isn't quite right. The problem you're seeing is that previously this was escaped as js (incorrect), and now it is escaped as text (correct). If you set your type as above to "text/javascript", it works in go 1.8:
<script type="text/javascript"> <div><%= something %></div> </script>
on 1.8 outputs:
<script type="text/javascript"> <div><%= something %></div> </script>
the one that fails is if you set the type to text/template or similar, which makes sense I guess as it is not js but might be annoying if your library uses <> as delimiters. Should work with text/template though if you mark those snippets as template.HTML type before including in an html/template.
If it is true, please don't use the text template as a quick fix. A lot if security thinking went into the html template and without it you will have xss all over your code.
Edit: sure enough, it validates type against know values and I assume jsx is not over of them.
Use <script type="text/ejs">?
<script type="<%= js_mime %>"> <div><%= something %>
then it won't be escaped presumably as js, but it will become js when it is run through the other templating system. sentiental have you tried that approach?
$ go get golang.org/x/build/version/go1.8rc1
$ go1.8rc1 download
$ go1.8rc1 version
go version go1.8rc1 darwin/amd64
$ go1.8rc1 build ...https://blog.gopheracademy.com/advent-2016/saga-go-dependenc...
I wanted to quickly test out the new struct type conversion behavior and obviously my code[1] doesn't compile on the normal playground.
Perhaps interesting to note, the `beta.golang.org`[2] homepage specifically adds an inline `display:none` style to the div containing the mini Go Playground which is normally on the `golang.org`[3] homepage - removing that style in the Chrome inspector, you can see the mini Playground, but it doesn't work. Upon closer inspection, the code to init the playground is still there, but the `playground.js` script isn't – the init code, however, checks for this so it doesn't throw any errors.
I like the attention to detail, at least – you don't want the homepage for a beta version to have the plaground running the current stable release version; that would be pretty confusing. Still, I wonder why the HTML and JS initialization code for the playground is still there? If they went through the effort to add a `display:none` style to the HTML and a condition to check if the Playground script is available, why not just remove it entirely?
Just my random thoughts - obviously not a big deal at all, I just found it interesting!
I assume that, so far, just no one did the work, they don't want to spend the additional resources on separate playgrounds or the go team doesn't consider it a good enough idea. I'd recommend either E-Mailing golang-nuts or directly opening an issue (after checking, that there is none so far).
umm, no, not automagically. the playground is restricted. it would require some work to be put in to make it work with the latest release. that work isn't available for free.
Maybe I'm stupid and just always make stupid comments, but I think the attitude you displayed with your "umm, no" is way too common around here. Is it too hard for you to not be condescending when making a counter argument?
Edit: After re-reading both my comment and yours, I'm not sure if you were using the "umm, no" innocently in response to the `(Or is there?)` at the end of my sentence, or if you were trying to say it in a condescending way. I'll give you the benefit of the doubt and assume it was the former. I'm not trying to be one of those SJW people who gets offended at any little thing.
Regarding the rest of your comment:
> the playground is restricted
What exactly do you mean by that?
> automagically
And that?
I'm referring to large RCs like this. I think a lot of people want to test out new features/changes without pulling the latest version to their machine right away.
That work is going to have to be done anyway before the final release, right? And I can't really imagine it would be a lot of work, I would think _maybe_ a few things would break, but otherwise it should work?
And if you think I mean to have the normal `play.golang.org` start using the latest RC, that's not what I mean - I would imagine it would either be on a separate subdomain, like `play.beta.golang.org`. Or, have a dropdown on the main Playground, but that might be potentially confusing?
The Playground is a very special build of Go. I don't even think it's open sourced, often because while you can't depend on security-by-obscurity you still don't necessarily want to just hand people the source to attack on their own. It's written to prevent people from abusing the playground, so for instance, the os package can't read real files, the time package returns constants for "time.Now()" rather than using the clock, and an arbitrary number of other changes are made to prevent abuse. How many changes it is I don't know exactly, but there's certainly a number of them. But, more importantly, the QA work for such a thing is quite substantial. Many of the changes would also preclude using the playground to investigate the new features; for instance, you can't test HTTP2 support on there since you can't open sockets or servers. Presumably updating it would require significant effort, and at the very least, it can't be afforded to make that a blocker for a release.
But now, this user has been heavily downvoted, which is aggressive, without any doubt. I really wish downvote features were out of the web, this is just group bullying. Upvoting is plenty enough to make good contributions raise above the others.
Go 1.8 will be the last release to support Linux on ARMv5E and ARMv6 processors: Go 1.9 will likely require the ARMv6K (as found in the Raspberry Pi 1) or later.
Does this mean that we will not be able to produce ARMv5 binaries or this is only a prerequisite for the compiler?Any ideas?
Go 1.8 will be Linux-only.
Go 1.9 should add Mac support back, and hopefully Windows if the right people have time to work on it.
I'm considering using Go for a small service that would live on my OpenWRT router.
What does this mean for me?
Depending on your hardware, you may run into issues with the size of Go binaries.
Off topic: If you use OpenWRT, check out the LEDE Project. It's a fork and development appears more active, but no stable releases yet.
Edit: found it -- disregard my last. Floating Point Unit.