Go language file types are mainly identified by suffixes. Common types include: .go: source code file.mod: module description file_test.go: test file.c: C language source code file_.s: assembly language source Code file.h: C language header file
List of Go language file types
Go language file types are identified by suffixes, Different types of suffixes represent different uses. The following are some common Go language file types:
Practical case:
Create a simple Go language program and use different file types:
// main.go (源代码文件) package main import "fmt" func main() { fmt.Println("Hello, Go!") }
// _test.go (测试文件) package main import "testing" func TestMain(t *testing.T) { want := "Hello, Go!" got := "Hello, Go!" if want != got { t.Errorf("want %q, got %q", want, got) } }
// go.mod (模块描述文件) module myapp require ( github.com/golang/protobuf v1.5.2 )
// 构建和运行程序 go build main.go ./main // 运行测试 go test
Output :
Hello, Go!
The above is the detailed content of List of Go language file types. For more information, please follow other related articles on the PHP Chinese website!