LoginSignup
1
0

More than 3 years have passed since last update.

main.goを複数ファイルに分ける

Last updated at Posted at 2020-08-15

コード

main.go
package main

func main() {
    test()
}
test.go
package main

import "fmt"

func test() {
    fmt.Printf("%s","Hello")
}

実行

  • main.goを指定するとエラーというか、test関数を読み込めないでいる
yuta:~/func $ go run main.go 
# command-line-arguments
./main.go:4:2: undefined: test

正しい実行

  • * で実行しよう!
yuta:~/func $ go run *.go
Hello

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0