Programming/golang

go run ./

구차니 2022. 4. 18. 19:15

 

$ cat hello.go 
package main

import "fmt"

func main() {
fmt.Println("Hello world")
hello()
}

$ cat func.go 
package main

import "fmt"

func hello() {
fmt.Println("Hello world 2")
}

$ go run .
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

$ go mod init
go: creating new go.mod: module go2
go: to add module requirements and sums:
go mod tidy

$ go run .
Hello world
Hello world 2