我无法使用package main在不同包中定义的结构。请注意,我正在正确导入其他包
我以大写字母开头命名结构及其字段,因为我在 Golang 中读到,这就是我们指示它是导出字段的方式。尽管如果包是导入的则不需要。
fsm.go
package fsm
import (
"fmt"
"strings"
)
// EKey is a struct key used for storing the transition map.
type EKey struct {
// event is the name of the event that the keys refers to.
Event string
// src is the source from where the event can transition.
Src string
}
测试.go
package main
import (
"encoding/json"
"fmt"
"github.com/looplab/fsm"
)
func main(){
Transitions := make(map[EKey]string)
}
Error: undefined EKey
qq_笑_17
慕码人8056858
不负相思意
相关分类