remote module specification
This commit is contained in:
parent
4da23b9537
commit
6b03f23916
27
go-testing.go
Normal file
27
go-testing.go
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//TestAbs comment needed
|
||||
func TestAbs(t *testing.T) {
|
||||
// TestAbs comment
|
||||
got := math.Abs(-1)
|
||||
if got != 1 {
|
||||
t.Errorf("Abs(-1) = %d; want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
//TestMain comment needed
|
||||
func TestMain(m *testing.M) {
|
||||
// call flag.Parse() here if TestMain uses flags
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func main() {
|
||||
TestAbs(&testing.T{})
|
||||
|
||||
}
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module go-learn
|
||||
module bitbucket.org/gmgauthier_ecs/go-learn
|
||||
|
||||
go 1.16
|
||||
|
||||
|
28
goroutines.go
Normal file
28
goroutines.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func f(from string) {
|
||||
for i := 0; i < 3; i++ {
|
||||
fmt.Println(from, ":", i)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
f("direct FIRST")
|
||||
|
||||
go f("goroutine one SECOND")
|
||||
go f("goroutine two THIRD")
|
||||
|
||||
go func(msg string) {
|
||||
fmt.Println(msg + " <IN MAIN> ")
|
||||
go f("goroutine three <IN MAIN> FOURTH")
|
||||
}("going")
|
||||
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println("done")
|
||||
}
|
Loading…
Reference in New Issue
Block a user