In golang its super easy to create a project to work on. Few versions before you need to use dep to maintain the packages which was itself and issue. Now simple use go modules to create your project.
In this article I will guide you on how to create and manage a project when working in GoLang.
Create A Folder For Your Project
This folder will be hold all your code and configuration and actually this is the folder where we are going to.
Create a project directory
Open terminal in that directory
Type
go mod init package-name
Example:
go mod init form-processing
Create a subfolder names as services
Inside that folder create a file mail.go
Paste the content below in this file:
package sendmail
import (
"fmt"
)
func SendMail() {
fmt.Println("This is from sendmail package")
}
Make sure you specify a package name of top and your function name starts with a capital letter. This is because a variable or function name that starts with a capital letter are exported in go.