برنامه نویسی

سلام جهان در 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.

نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

همچنین ببینید
بستن
دکمه بازگشت به بالا