📜  golang 从文件导入函数 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:56.680000             🧑  作者: Mango

代码示例1
////////////////////////////////////
//This is the code inside test1.go//
////////////////////////////////////

package main

import (
    L "./lib" // This will import ALL the files inside the lib folder
)

func main() {
    L.Demo()
}

///////////////////////////////////////////////////////////////////////////
//This is the code inside test2.go, this is inside a subfolder called lib//
///////////////////////////////////////////////////////////////////////////

package lib // All the files inside lib will have the same package name

import "fmt"

// This func must be Exported, Capitalized, and comment added.
func Demo() {
    fmt.Println("HI")
}