Back to Home

สอน Go (Golang) เบื้องต้น: เริ่มเขียนโปรแกรมแรกของคุณ (Hello, World!)

Go Developer20 ธันวาคม 2567Go Basics
GoGolangProgrammingBackendสอน Go

Go (หรือ Golang) เป็นภาษาโปรแกรมที่สร้างโดย Google เน้นความเรียบง่าย, ประสิทธิภาพ และ Concurrency

ติดตั้ง Go

ไปที่ golang.org/dl/ แล้วดาวน์โหลดเวอร์ชันล่าสุดสำหรับ OS ของคุณ

Hello, World

// hello.go package main import "fmt" func main() { fmt.Println("Hello, World!") }

รันโปรแกรม

go run hello.go

ตัวแปรและ Data Types

package main import "fmt" func main() { var name string = "Gensics" age := 30 // Short assignment pi := 3.14 isLearning := true fmt.Printf("Name: %s, Age: %d, Pi: %f, Learning: %t\n", name, age, pi, isLearning) }

สรุป

Go เป็นภาษาที่มี Syntax กระชับและเรียนรู้ง่าย เหมาะสำหรับผู้ที่ต้องการสร้างโปรแกรมที่มีประสิทธิภาพสูง