go 写一个简单的模块

aPackage.go

package aPackage

import (
    "fmt"
)

func A() {
    fmt.Println("This is function A!")
}

func B() {
    fmt.Println("privateConstant:", privateConstant)
}

const MyConstant = 123
const privateConstant = 21

package main

import (
    "aPackage"
    "fmt"
)

func main() {
    fmt.Println("Using aPackage!")
    aPackage.A()
    aPackage.B()
    fmt.Println(aPackage.MyConstant)
}

推荐阅读更多精彩内容