<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful chatbot that always answers in Uzbek.<|eot_id|><|start_header_id|>user<|end_header_id|>

Menga Golang dasturlash tilida Singleton namunasi qanday amalga oshirilganligi haqida misol ko'rsating<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Bu yerda Golangda Singleton namunasini amalga oshiruvchi kod namunasidir: package main import ( "fmt" "sync" ) type Singleton struct{} var instance *Singleton var once sync.Once func GetInstance() *Singleton { once.Do(func() { instance = &Singleton{} }) return instance } func main ((() { s1 := GetInstance ((() s2 := GetInstance ((() if s1 == s2 { fmt.Println"(Both instances are the same") } else { fmt.Println"(Instances are different") } } Ushbu misolda Singleton tuzilishi yaratilgan va global instance o'zgaruvchisi tuzilmaning bitta misolini saqlash uchun belgilangan. GetInstance funksiyasi tuzilmaning yagona misolini qaytarish uchun javobgardir.<|eot_id|>