Advertisement
Uhuuuyy

struct.go

May 26th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.51 KB | Source Code | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var data = map[string]mahasiswa {
  6.         "11119829" : {
  7.             "Dimas Raihan Pratama",
  8.             "4KA21",
  9.         },
  10.         "11112222" : {
  11.             "Ahmad Fulan",
  12.             "4KA01",
  13.         },
  14.     }
  15.  
  16.     var search string
  17.     fmt.Print("Masuukan NPM Anda: ")
  18.     fmt.Scanf("%s", &search)
  19.  
  20.     var value, ok = data[search]
  21.     if ok {
  22.         fmt.Printf("Nama Anda %s \nKelas Anda %s", value.Nama, value.Kelas)
  23.     } else {
  24.         fmt.Println("Data Tidak Ditemukan")
  25.     }
  26. }
  27.  
  28. type mahasiswa struct {
  29.     Nama string
  30.     Kelas string
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement