package main

import "fmt"

type PersonInfo struct {
    ID      string
    Name    string
    Address string
}

func main() {
    var personDB map[string]PersonInfo
    personDB = make(map[string]PersonInfo)
    personDB[", "Tom", "Room 203..."}
    personDB[", "Jack", "Room 1..."}

    person, ok := personDB["]
    if ok {
        fmt.Println("Fond person", person.Name, "with ID 1234.")
    } else {
        fmt.Println("Did not find person with ID1234.")
    }
}

D:/gocode/gocode.exe [D:/gocode]

Did not find person with ID1234.

成功: 进程退出代码 0.

c:/go/bin/go.exe build [D:/gocode]

成功: 进程退出代码 0.

D:/gocode/gocode.exe [D:/gocode]

Fond person Tom with ID 1234.

成功: 进程退出代码 0.

05-11 09:08