当前位置:网站首页>Go-3-the first go program

Go-3-the first go program

2022-07-05 10:42:00 hahyyy

first Go Program ( stay Linux Under the system )

Create a new file ~/code/example.go

//  Declare the package where the file is located , If it is the main program, it is main 
// Go Language uses packages to organize code 
//  Generally, a folder is a package 
//  The type or method can be exposed in the package for use by other packages 
package main 

//  Import library 
// fmt yes Go A standard library of languages / package 
//  Used to process standard input and output  
import "fmt" 

// main  Function is the entry to the whole program ,main The package name of the function must also be  `main` 
//  The main package must contain a main function 
func main() { 
    //  call fmt Bag Println Method , Output information on the screen 
    fmt.Println("Hello World!")
}

//  A line represents the end of a statement , Multiple statements are written on the same line , Must be used ; Artificial differentiation 
//  Single-line comments ://
//  Multiline comment :/* --- */
//  identifier : Same as python Identifier rule 

Run code

  • Direct operation

  • Compile and then execute

 

 

Go Language configuration

Configure the installation source

 

原网站

版权声明
本文为[hahyyy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051022404240.html