> For the complete documentation index, see [llms.txt](https://easonwang.gitbook.io/golang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easonwang.gitbook.io/golang/an-zhuang-golang/export-yu-import.md).

# export 與 import

使用以下方法即可 import 另一個資料夾的 func，與go mod 不同的是 import時需要多寫上路徑。

1. 新增一個資料夾與一個要export的檔案

![](/files/-MBRSZdBaksa5tLvRj4D)

```go
package concurrency

import (
	"fmt"
)

func Say(s string) {
	fmt.Print(s)
}
```

> 記得export 的 function 第一個字要大寫

2\.  新增 要 import的檔案

hello.go

```go
package main;

import (
	concurrency "./concurrency"
)

func main() {
	concurrency.Say("hello");
}
```

![](/files/-MBRT-BP_RQ9KZ3KAFoD)

之後即可。

## &#x20;使用 go mod 的話 import 只要放入 go mod 名稱在前面即可

```
go mod init test-backend
```

例如在 route 檔案可使用如下：

```
package routes

import (
	controllers "test-backend/controllers"
)

func CatchphrasesRoute(route fiber.Router) {
	route.Get("/", controllers.GetAllCatchphrases)
}
```
