package main
import (
“os”
“fmt”
“net/http”
“io”
)
//声明nodeInfo节点,代表各个小国家
type nodeInfo struct {
//节点名称
id string
//节点路径
path string
//http响应,每个终端代表一个小国家
writer http.ResponseWriter
}
//创建map,存处各个国家的IP地址
//make()形成一个对象,可以生成地址便于操作
var nodeTable = make(map[string]string)
func main() {
//接收终端参数
//可以读多个参数
//for a := 1; a < 3; a++ {
userId := os.Args[1]
fmt.Println(userId)
//存储四个国家的IP地址
nodeTable = map[string]string {
“N0”:“localhost:1111”,
“N1”:“localhost:1112”,
“N2”:“localhost:1113”,
“N3”:“localhost:1114”,
}
//创建国家对象
//为结构体赋值指定个数的参数
node:=nodeInfo{id:userId,path:nodeTable[userId]}
//http协议的回调函数