On Thu, May 23, 2013 at 10:41 PM,
<nik...@nikkau.net> wrote:
I have to code a very simple program with the need to distribute the binary for OSX and Windows platforms, that seems a perfect mission for Go (and a good pretext to learn it).
So, I'm new to Go and my program need to read the clipboard, the way to do it is very different between Windows and OSX.
How I can code a function which behave differently for these platforms?
I guess that I could use a Switch, but maybe there is a better way?
use special filenames (windows.go and darwin.go) or build tags.
for example, you can write these two files implementing the same API to other part of your program:
// windows.go
package clipboard
func Get() string { /* blah blah */ }
func Set(s string) { /* blah blah */ }
// darwin.go
package clipboard
func Get() string { /* blah blah */ }
func Set(s string) { /* blah blah */ }