first hello module
This commit is contained in:
parent
dfe937fc42
commit
d5ab4eeb57
3 changed files with 26 additions and 0 deletions
3
hello/go.mod
Normal file
3
hello/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module hello
|
||||||
|
|
||||||
|
go 1.22.1
|
11
hello/hello.go
Normal file
11
hello/hello.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func Hello() string {
|
||||||
|
return "Hello, world!"
|
||||||
|
}
|
||||||
|
|
||||||
|
func main () {
|
||||||
|
fmt.Println(Hello())
|
||||||
|
}
|
12
hello/hello_test.go
Normal file
12
hello/hello_test.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestHello(t *testing.T) {
|
||||||
|
given := Hello()
|
||||||
|
expected := "Hello, world!"
|
||||||
|
|
||||||
|
if given != expected {
|
||||||
|
t.Errorf("given: %v, expected: %v", given, expected)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue