Assume we have two file, of two packages. Here i will use web.go extension to run this example.

 

These two files are located in the same folder.

test.go

package main

import (
"web"
"./user"// Please pay attention here
)

func hello(val
string) string{
return "Hello, world"
}

func main () {
web.Get(
"/(.*)", user.Create)
web.Run(
"0.0.0.0:9999")
}

 

user.go

package user

func Create(val
string) string{
return "create"
}

func Hello(val
string) string{
return "Hello, world"
}

 

The steps to run the app.

1. Compile the user.go first!

8g user.go

 

2. Compile and run the test.go

8g test.go
8l test.
8
.
/8.out

 

Here are two steps you have to be aware of:

A. How to import the user package ==> import ("./user")

B. First compile the user.go!

相关文章:

  • 2021-09-20
  • 2021-09-15
  • 2022-12-23
  • 2021-04-24
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2021-09-30
  • 2021-05-23
  • 2022-12-23
  • 2021-12-14
  • 2022-01-01
相关资源
相似解决方案