برنامه نویسی
سلام جهان در Golang – انجمن DEV
- ابتدا بسته را اضافه کنید اصلی در برنامه شما:
package main
Every Go file must start with a package name statement. Packages provide code encapsulation and reuse. The name of the package here is main.
- پس از اضافه کردن واردات بسته اصلی “fmt” بسته در برنامه شما:
import(
"fmt"
)
Import the fmt package, which will be used to print text to the standard output in the main function.
- اکنون کد را در تابع main برای چاپ hello world به زبان Go بنویسید:
func main() {
fmt.Println("Hello World")
}
func main():
The main function is a special function that is the entry point of a Go program. The main function must be included in the main package. { and } denote the start and end of the main function.
fmt.Println (“سلام جهان”):
The Println function in the fmt package is used to print text to standard output.