From 3e45412327a2654a77944249962b3652e6142299 Mon Sep 17 00:00:00 2001
From: Ondřej Surý src/pkg/c
-include ../../../Make.$(GOARCH) +include ../../../Make.inc TARG=container/vector GOFILES=\ @@ -80,7 +80,7 @@ Outside the Go source tree (for personal packages), the standard form is-include $(GOROOT)/src/Make.$(GOARCH) +include $(GOROOT)/src/Make.inc TARG=mypackage GOFILES=\ @@ -98,6 +98,14 @@ even if$(GOROOT)
contains spaces. This makes it easy for programmers to try Go. ++If you have not set
+$GOROOT
in your environment, +you must rungomake
to use this form of makefile. +Gomake
also takes care to invoke GNU Make +even on systems where it is installed asgmake
+rather thanmake
. +
TARG
is the target install path for the package, the string that clients will use to import it. @@ -131,8 +139,8 @@ cd $GOROOT/src/pkgto update the dependency file
Make.deps
. -(This happens automatically each time you runmake all
-ormake build
.) +(This happens automatically each time you runall.bash
+ormake.bash
.)@@ -169,6 +177,32 @@ Writing clean, idiomatic Go code is beyond the scope of this document. that topic.
+Building programs
+To build a Go program with gomake, create a Makefile alongside your program's +source files. It should be similar to the example above, but include +
Make.cmd
instead ofMake.pkg
: + ++include $(GOROOT)/src/Make.inc + +TARG=helloworld +GOFILES=\ + helloworld.go\ + +include $(GOROOT)/src/Make.cmd ++ +Running
+ +gomake
will compilehelloworld.go
+and produce an executable namedhelloworld
in the current +directory. ++Running
+gomake install
will buildhelloworld
if +necessary and copy it to the$GOBIN
directory +($GOROOT/bin/
is the default). +Testing
@@ -259,7 +293,7 @@ Finally, the
Makefile
:-include $(GOROOT)/src/Make.$(GOARCH) +include $(GOROOT)/src/Make.inc TARG=numbers GOFILES=\ @@ -269,13 +303,13 @@ include $(GOROOT)/src/Make.pkg-Running
make install
will build and install the package to +Runninggomake install
will build and install the package to the$GOROOT/pkg/
directory (it can then be used by any program on the system).-Running
make test
(or just running the command +Runninggomake test
(or just running the commandgotest
) will rebuild the package, including thenumbers_test.go
file, and then run theTestDouble
function. The output "PASS
" indicates that all tests passed -- cgit v1.2.3