Dave Cheney

History, Economics and Technology

A sample Makefile to build multi package Go projects

  • Edit
  • Delete
  • Tags
  • Autopost

Notes

  1. For packages (those including $(GOROOT)/src/make.pkg) they must be called with the install target so they resulting .a is copied into the Go distribution root, so it is visible to the linker when building other packages.
  2. For commands (those including $(GOROOT)/src/make.cmd) calling the install target will copy the resulting binary command into the $GOROOT/bin directory, which may not be what you want.
  3. The top level clean target calls the nuke target in all packages (see note 1) to ensure that the linker will not see stale versions of the compiled package. Simply calling the clean target in a package will not remove the version that is visible to the linker.

Filed under  //

  • golang
  • programming

Using Multicast UDP in Go

  • Edit
  • Delete
  • Tags
  • Autopost

Support for joining and leaving a Multicast UDP group was recently added to Go. You can view the godoc for UDPConn.JoinGroup and UDPConn.LeaveGroup online at Gustavo Niemeyer's goneat

I've put an example program for using Multicast to dump mDNS on GitHub Here is an example of my iPhone waking up on the local wlan.
lucky(~/devel/mdns-test) % ./mdns-test 
2011/02/19 10:49:52 ;; ->>HEADER

Read more about it at https://github.com/davecheney/mdns-test

Filed under  //

  • golang
  • multicast
  • programming

Debugging gotest

  • Edit
  • Delete
  • Tags
  • Autopost
Having trouble with your gotests? Then try this protip. gotest can prepend the contents of $GORUN when executing the test binary. A great example could be
$ GORUN=/opt/local/bin/fsf-gdb gotest
Why not /usr/bin/gdb? Well, if you're running a Mac, then the default version of gdb doesn't understand DWARF3 symbols.

Filed under  //

  • golang
  • programming

ack! and Go source files

  • Edit
  • Delete
  • Tags
  • Autopost
I'm a big fan of ack!, but out of the box on MacPorts, there is no support for .go source files. The fix to this is simple; make sure you add
--type-set=golang=.go
to your ~/.ackrc
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.