first commit
This commit is contained in:
7
createAGoModule/hello/go.mod
Normal file
7
createAGoModule/hello/go.mod
Normal file
@ -0,0 +1,7 @@
|
||||
module example.com/hello
|
||||
|
||||
go 1.17
|
||||
|
||||
replace example.com/greetings => ../greetings
|
||||
|
||||
require example.com/greetings v0.0.0-00010101000000-000000000000
|
BIN
createAGoModule/hello/hello
Executable file
BIN
createAGoModule/hello/hello
Executable file
Binary file not shown.
34
createAGoModule/hello/hello.go
Normal file
34
createAGoModule/hello/hello.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"example.com/greetings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Set properties of the predefined Logger, including
|
||||
// the log entry prefix and a flag to disable printing
|
||||
// the time, source file, and line number.
|
||||
log.SetPrefix("greetings: ")
|
||||
log.SetFlags(0)
|
||||
|
||||
|
||||
// Request a greeting message.
|
||||
// message, err := greetings.Hello("Gladys")
|
||||
|
||||
// A slice of names.
|
||||
names := []string{"Gladys", "Samantha", "Darrin"}
|
||||
message, err := greetings.Hellos(names)
|
||||
|
||||
// If an error was returned, print it to the console and
|
||||
// exit the program.
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// If no error was returned, print the returned message
|
||||
// to the console.
|
||||
fmt.Println(message)
|
||||
}
|
Reference in New Issue
Block a user