4 ms·
I've started using the builtin "println" function for stdout debugging to get around the Damnable Use Requirement. It works without any packages imported, so th
by rsaarelm 14y ago
I've started using the builtin "println" function for stdout debugging to get around the Damnable Use Requirement. It works without any packages imported, so that the very low-level stuff can tell it's alive without a full stdio library stack in place.
- genwin 14y agoI use this too. It seems undocumented.
- rsaarelm 14y agoIt's documented here, with an admonition not to expect the feature to remain in all future versions: http://golang.org/ref/spec#Bootstrapping http://golang.org/ref/spec#Bootstrapping
- luriel 14y agoyou can also add just after import "fmt" add: var _ = fmt.Println That way it will never complain that fmt is imported but not used. Still, I never had need for this. Once you have written a bit of code the import list remains relatively stable.
- Jabbles 14y agoMissing "var", and a bit ugly, but could be used if it's annoying you :) http://play.golang.org/p/vVnZWobca9 http://play.golang.org/p/vVnZWobca9
- rsaarelm 14y agoI don't want to commit temporary debug cruft to version control, so I'd still need to keep adding and removing that whenever I do a commit. Though I guess I could just always skip it with git add --patch. I do have need for some solution, since I have packages that don't do anything with strings and therefore don't import fmt, but which still get bugs which I need to debug with the stdout. One more robust approach would be to fit a complete configurable logging system permanently in place.