Start by creating a ./x/nameservice/alias.go file. The main reason for having this file is to prevent import cycles. You can read more about import cycles in go here: Golang import cycles
First start by importing the "types" folder you have created.
package nameservice
import (
"github.com/cosmos/sdk-application-tutorial/x/nameservice/types"
)There are three kinds of types we will create in the alias.go file.
- a constant, this is where you will define immutable variables.
const (
ModuleName = types.ModuleName
RouterKey = types.RouterKey
StoreKey = types.StoreKey
)- a variable, which you will define to contain information such as your messages.
var (
NewMsgBuyName = types.NewMsgBuyName
NewMsgSetName = types.NewMsgSetName
NewWhois = types.NewWhois
ModuleCdc = types.ModuleCdc
RegisterCodec = types.RegisterCodec
)- a type, here you will define the types you have created in the types folder.
type (
MsgSetName = types.MsgSetName
MsgBuyName = types.MsgBuyName
QueryResResolve = types.QueryResResolve
QueryResNames = types.QueryResNames
Whois = types.Whois
)Now you have aliased your needed constants, variables, and types. We can move forward with the creation of the module.