From 50104cc32a498f7517a51c8dc93106c51c7a54b4 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Wed, 20 Apr 2011 15:44:41 +0200 Subject: Imported Upstream version 2011.03.07.1 --- doc/code.html | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'doc/code.html') diff --git a/doc/code.html b/doc/code.html index 9236cf263..cdc60b071 100644 --- a/doc/code.html +++ b/doc/code.html @@ -229,7 +229,7 @@ run gotest one_test.go.

If your change affects performance, add a Benchmark function (see the gotest command documentation) -and run it using gotest -benchmarks=.. +and run it using gotest -test.bench=..

@@ -322,3 +322,47 @@ reported. See the gotest documentation and the testing package for more detail.

+ +

Architecture- and operating system-specific code

+ +

First, a disclaimer: very few Go packages should need to know about the +hardware and operating system they run on. In the vast majority of cases the +language and standard library handle most portability issues. This section is +a guide for experienced systems programmers who have a good reason to write +platform-specific code, such as assembly-language support for fast +trigonometric functions or code that implements a common interface above +different operating systems.

+ +

To compile such code, use the $GOOS and $GOARCH +environment variables in your +source file names and Makefile.

+ +

For example, this Makefile describes a package that builds on +different operating systems by parameterizing the file name with +$GOOS.

+ +
+include $(GOROOT)/src/Make.inc
+
+TARG=mypackage
+GOFILES=\
+	my.go\
+	my_$(GOOS).go\
+
+include $(GOROOT)/src/Make.pkg
+
+ +

The OS-specific code goes in my_linux.go, +my_darwin.go, and so on.

+ +

If you follow these conventional parameterizations, tools such as +goinstall will work seamlessly with your package: +

+ +
+my_$(GOOS).go
+my_$(GOARCH).go
+my_$(GOOS)_$(GOARCH).go
+
+ +

The same holds for .s (assembly) files.

-- cgit v1.2.3