This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func adder() (func(int) int) { | |
var x int | |
return func(delta int) int { | |
x += delta | |
return x | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func adder() (func(int) int) { | |
var x int | |
return func(delta int) int { | |
x += delta | |
return x | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func adder() (func(int) int) { | |
var x int | |
return func(delta int) int { | |
x += delta | |
return x | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func adder() (func(int) int) { //declare function adder() with the function literal func(int) as a parameter of type int | |
var x int | |
return func(delta int) int { | |
x += delta | |
return x | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func f() { | |
for i := 0; i < 10; i++ { | |
g := func(i int) { | |
fmt.Printf("%d", i) | |
} | |
g(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"flag" // command line option parser | |
) | |
var omitNewline = flag.Bool("n", false, "don't print final newline") | |
const ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"./iopkg" | |
"fmt" | |
"os" | |
) | |
func main() { | |
hello := []byte("hello, world\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package file | |
import ( | |
"os" | |
"syscall" | |
) | |
type File struct { | |
fd int // file descriptor number | |
name string //file name at Open time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A version of echo - go/docs/GoCourseDay1.pdf slide 59 | |
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// go/doc/GoCourseDay1.pdf slide 62 | |
package main | |
import ( | |
"fmt" | |
"./transcendental" | |
) | |
var twoPi = 2 * transcendental.Pi //decl computes twoPi | |
func main() { |
OlderNewer