Google Cloud Debugger: use local source, Go and Node.js support, IntelliJ plugin
googlecloudplatform.blogspot.com
googlecloudplatform.blogspot.com
I spent the next 30 minutes trying to figure out how to add printline debugging to the standard library. I saw the precise line of code it was failing on, so I added some logging code above it to print out more info. Nothing happened. I tried to rebuild the file. There was no obvious way to do this. I googled for "golang recompile standard library." There was no clear, simple answer. I seemed to be expected to read all of the documentation in order to do this seemingly-simple thing. I went on Freenode and asked how to do it. Crickets.
I was being intellectually lazy, a cardinal sin. Obviously, the solution was to read the documentation, learn about GOPATH, learn how and why the source code was laid out the way it was, understand how to make my own package, then try to figure out how to make changes to existing packages.
But it's a step backwards. I'm staring at the code. I made changes to it. Why does it require a magical incantation to make those changes have an effect? Why can't it detect that the code changed, and do whatever's necessary to apply those changes? Or at least let me type "go make zlib.go" and be done with it? Yeah, "make" isn't a valid command. I'm supposed to "build" a package. But I'm not trying to build a package. I'm trying to run someone's freshly-cloned Go project.
The whole thing made me feel dumb and outdated.
I like everything else about Go and hope they remove that cruft from such a great language in version 2 or so. Go should learn from C/C++ in this regard.
Learning from C++ builds seems like a cruel joke – not sure if trolling or not ;-)
You can read more detailed explanation by Dave (author of alternative Go build system - gb) here: http://dave.cheney.net/2013/10/15/how-does-the-go-build-comm...
> error
> go's standard compression lib
> go's standard gif lib
> the project tries to write a gif to disk
It was very easy to grep the stdlib for the error message, which turned out to be in Go's compression lib. Great! I opened it up and started reading through it.Somehow, the compression lib was receiving an invalid parameter. Therefore, either Go's standard gif library was responsible for the problem (extremely unlikely) or the project was generating some kind of "invalid" gif data, or some gif settings that Go's gif lib didn't handle correctly when writing to disk.
Printline debugging is the fastest way to figure out this type of problem. Print out everything, every single parameter, all the way up the stack. Eventually you'll spot the logic that's failing to handle the data. Trouble was, I had no clue how to modify go's stdlib. Nothing I did seemed to have any effect whatsoever.
It sounds like you're saying the solution is to copy the gif lib to my local gopath like foo/gif, rebuild it there, then modify the project to import from foo/gif instead of image/gif. Ok, cool. I'll try this, thanks!
Since the gif lib imports the compression lib, it sounds like I'll have to copy both libs, then try to modify the gif lib to use the local copy of the compression lib. Ok, sure. At least now I have a way of making progress.
The project ran on the author's machine without any problems, so I bet I'm using a different version of Go. If I could figure out which version they were using, I could just downgrade to that. Problem solved. Unfortunately, I don't think this information is present in the project's repository, which is just a single .go file. (I guess I could check when the most recent commit was, then figure out what version of Go was in use back then...)
Anyway. Thanks for your help.
> I'm trying to run someone's freshly-cloned Go project.
"go run x.go" will do that.
For a side project, I've been using Go on the App Engine for the past year, writing with Sublime Text. Sublime has a Go plugin that does some syntax checking, and App Engine reloads automatically. It's not that bad. My site isn't large but I find it more enjoyable than writing Java. I started with Python but found Go is significantly faster:
http://www.h4labs.com/dev/ios/swift.html
I also generate my iOS app localization files using a small Go program that I wrote.
for anything bigger, when code #reasonably# grows and span among 10+ developers, break-debug-change is much more productive than log.PrintLn all over the palces and figuring out myself, or interrupt my colleague to explain sth to me.
How can they put a breakpoint/inspect objects at arbitrary locations without this slowdown? Maybe they have a modified cPython interpreter?
Edit: lots of C code is the answer[1]
1. https://github.com/GoogleCloudPlatform/cloud-debug-python/tr...
This source file implements all of it: https://github.com/GoogleCloudPlatform/cloud-debug-python/bl...
The Cloud Debugger is different from your tradition debugger as it optimizes for application speed. For example, it would capture values, let the thread continue and run, and only then serialize is back to the Cloud Debugger server.
But many (most?) are willing to accept that trade-off.
I haven't researched this at all, but if you can use your own software on your own computer (e.g. IntelliJ) for the debugging UI, then you retain control over at least _part_ of your computing.
Configure project SDK for Go.
Right click main.go -> Select debug
I'm using IntelliJ 15 on OS X. Not certain it's as easy on all platforms.
see the current agent code on https://github.com/GoogleCloudPlatform/cloud-debug-java
But I guess that is not in the realm of current technology.
There Cloud Debugger service exposes the clouddebugger API, which actually has two parts. The Debugger (which is intended for the UI) and the Controller (which is intended for the agent to interface).
Is the server code open-source as well?
The server side code is not open-source, mainly for use of internal technologies. But why do you really need it? Google offers it's usage for free.