update book code

This commit is contained in:
Unknwon
2015-03-03 12:25:25 -05:00
parent b8c82ba4e5
commit eab1d98ba8
465 changed files with 15392 additions and 1572 deletions

View File

@@ -1,7 +1,7 @@
include $(GOROOT)/src/Make.inc
TARG=rand
CGOFILES=\
c1.go\
include $(GOROOT)/src/Make.inc
TARG=rand
CGOFILES=\
c1.go\
include $(GOROOT)/src/Make.pkg

View File

@@ -1,13 +1,13 @@
// c1.go
package rand
// #include <stdlib.h>
import "C"
func Random() int {
return int(C.random())
}
func Seed(i int) {
C.srandom(C.uint(i))
}
// c1.go
package rand
// #include <stdlib.h>
import "C"
func Random() int {
return int(C.random())
}
func Seed(i int) {
C.srandom(C.uint(i))
}

View File

@@ -1,13 +1,13 @@
// c2.go
package print
// #include <stdio.h>
// #include <stdlib.h>
import "C"
import "unsafe"
func Print(s string) {
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
C.fputs(cs, (*C.FILE)(C.stdout))
}
// c2.go
package print
// #include <stdio.h>
// #include <stdlib.h>
import "C"
import "unsafe"
func Print(s string) {
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
C.fputs(cs, (*C.FILE)(C.stdout))
}

View File

@@ -1,7 +1,7 @@
include $(GOROOT)/src/Make.inc
TARG=test
GOFILES=\
test1.go\
test2.go\
include $(GOROOT)/src/Make.cmd
include $(GOROOT)/src/Make.inc
TARG=test
GOFILES=\
test1.go\
test2.go\
include $(GOROOT)/src/Make.cmd

View File

@@ -1,9 +1,9 @@
#!/bin/bash
FILES=~/goprograms/compiletest/*.go
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f stores current file name
# cat $f
6g $f >> compout
done
#!/bin/bash
FILES=~/goprograms/compiletest/*.go
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f stores current file name
# cat $f
6g $f >> compout
done

View File

@@ -1,2 +1,2 @@
FOR %%X in (*.go) DO 8g %%X >> compout
FOR %%X in (*.go) DO 8g %%X >> compout

View File

@@ -1,9 +1,9 @@
set GOROOT=E:\Go\GoforWindows\gowin32_release.r59\go
set GOBIN=$GOROOT\bin
set PATH=%PATH%;$GOBIN
set GOARCH=386
set GOOS=windows
echo off
8g %1.go
8l -o %1.exe %1.8
%1
set GOROOT=E:\Go\GoforWindows\gowin32_release.r59\go
set GOBIN=$GOROOT\bin
set PATH=%PATH%;$GOBIN
set GOARCH=386
set GOOS=windows
echo off
8g %1.go
8l -o %1.exe %1.8
%1