请问:
1、Go语言的模块化开发是否就是一个.go文件就是一个模块?还是说package xxx
代表一个模块呢?
如下代码:
package conditions
import (
"fmt"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
)
var ErrPodCompleted = fmt.Errorf("pod ran to completion")
func PodRunning(event watch.Event) (bool, error) {
switch event.Type {
case watch.Deleted:
return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
}
switch t := event.Object.(type) {
case *v1.Pod:
switch t.Status.Phase {
case v1.PodRunning:
return true, nil
case v1.PodFailed, v1.PodSucceeded:
return false, ErrPodCompleted
}
}
return false, nil
}
func PodCompleted(event watch.Event) (bool, error) {
switch event.Type {
case watch.Deleted:
return false, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, "")
}
switch t := event.Object.(type) {
case *v1.Pod:
switch t.Status.Phase {
case v1.PodFailed, v1.PodSucceeded:
return true, nil
}
}
return false, nil
}
2、Go语言的模块化开发和TypeScript不一致,TypeScript是使用export 导出想要导出的类/变量/type等,但是Go是所有的模块内定义的都是公开的,别人都可以import是吗?
大写字母开头是公开的,小写字母开头的不是。