Erhan Yakut Software Developer @Binalyze | Founder @Passwall | Golang Enthusiast | Open Sorcerer

Go Programlama Dili (Golang)’nde Dizi İçinden Rastgele Veri Çağırmak

14 sec read

Go kurulumu

Go programlama dilinde (Golang) diğer dillerde olduğu gibi diziler mevcuttur. Bazen dizi elemanlarının tamamını değil de dizi içerisinden rastgele bir veriyi/elemanı çağırmak isteriz. İşte böyle bir durumda aşağıdaki örnek koddan faydalanabilirsiniz.

import (
   "time"
   "math/rand"
)

...

words := []string{
                  "Araba",
                  "Ev",
                  "Okul",
                  "Sinema",
                  "Bilgisayar",
                  }

//Rastgele sayı üretme kodu
rand.Seed(time.Now().Unix()) 

word := words[rand.Intn(len(words))]
Erhan Yakut Software Developer @Binalyze | Founder @Passwall | Golang Enthusiast | Open Sorcerer

Designing an Endpoint Management Platform

Managing endpoints in enterprise environments is a recurring challenge. As organizations grow, manual operations become unmanageable, visibility decreases, and responding to incidents takes longer...
Erhan Yakut
2 min read

Iterate, Slice, and Deduplicate: Go’s New Tools for Cleaner…

Go keeps evolving — not through radical changes, but through small, elegant additions that make everyday programming smoother. Three of the newest additions to...
Erhan Yakut
1 min read

Retrieving the Correct Hostname on macOS

When dealing with macOS systems, retrieving the correct hostname can be tricky, especially in environments where DHCP and reverse lookup mechanisms are in play....
Erhan Yakut
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *