The startup application in golang that returns a greeting for the specified person.
Let's write the following code into the file named hello.go:
package main
import (
"fmt"
"github.com/ugurpy/greetings"
)
func main() {
message, err := greetings.Hello("uğur")
if err != nil {
fmt.Println(err)
}
fmt.Println(message)
// A slice of names for Hellos func.
names := []string{"Birdal", "Uğur", "Eren"}
messages, err2 := greetings.Hellos(names)
if err2 != nil {
fmt.Println(err2)
}
for _, msg := range messages {
fmt.Println(msg)
}
}
add dependencies to current module and install them:
➜ go get github.com/ugurpy/greetings
Let's run the code:
➜ go run hello.go
Hi, uğur. Welcome!
Hi, Birdal. Welcome!
Hi, Uğur. Welcome!
Hi, Eren. Welcome!