create a folder for the Go module, as below
mkdir mymodule
cd mymodule
Issue the Create Module command in terminal as following, here "github.com/freedomtutorials/mymodule" is the name of the module which we are going to create, you can replace with your module name
go mod init github.com/freedomtutorials/mymodule
the file go.mod will be created and the below output will be produced
$ go mod init github.com/freedomtutorials/mymodule
go: creating new go.mod: module github.com/freedomtutorials/mymodule
In Go, if a function name starts with a capital letter will be available to be called by a function from same package or other package. This is known in Go as an exported name.
create a file mymodule.go in the current folder, and open in text editor paste the following code into mymodule.go and save the file
package mymodule
import "fmt"
func MyFunc(name string) string {
message := fmt.Sprintf("Hello, %v. Welcome!", name)
return message
}
how to use range in golang
posted on 2022-05-03 08:28:11 - Go lang Tutorials
find variable type in golang
posted on 2022-05-03 05:24:55 - Go lang Tutorials