func (sd *steamDirectory) Initialize() error {
	sd.Lock()
	defer sd.Unlock()
	client := new(http.Client)
	resp, err := client.Get(fmt.Sprintf("https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?cellId=0"))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	r := struct {
		Response struct {
			ServerList []string
			Result     uint32
			Message    string
		}
	}{}
	if err = json.NewDecoder(resp.Body).Decode(&r); err != nil {
		return err
	}
	if r.Response.Result != 1 {
		return fmt.Errorf("Failed to get steam directory, result: %v, message: %v\n", r.Response.Result, r.Response.Message)
	}
	if len(r.Response.ServerList) == 0 {
		return fmt.Errorf("Steam returned zero servers for steam directory request\n")
	}
	sd.servers = r.Response.ServerList
	sd.isInitialized = true
	return nil
}
// Get server list from steam directory and save it for later
Get server list from steam directory and save it for later
// Get server list from steam directory and save it for later
func (sd *steamDirectory) Initialize() error {
	sd.Lock()
	defer sd.Unlock()
	client := new(http.Client)
	resp, err := client.Get(fmt.Sprintf("https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?cellId=0"))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	r := struct {
		Response struct {
			ServerList []string
			Result     uint32
			Message    string
		}
	}{}
	if err = json.NewDecoder(resp.Body).Decode(&r); err != nil {
		return err
	}
	if r.Response.Result != 1 {
		return fmt.Errorf("Failed to get steam directory, result: %v, message: %v\n", r.Response.Result, r.Response.Message)
	}
	if len(r.Response.ServerList) == 0 {
		return fmt.Errorf("Steam returned zero servers for steam directory request\n")
	}
	sd.servers = r.Response.ServerList
	sd.isInitialized = true
	return nil
}
func ( sd * steamDirectory ) Initialize ( ) error { sd . Lock ( ) defer sd . Unlock ( ) client := new ( http . Client ) resp , err := client . Get ( fmt . Sprintf ( " " ) ) if err != nil { return err } defer resp . Body . Close ( ) r := struct { Response struct { ServerList [ ] string Result uint32 Message string } } { } if err = json . NewDecoder ( resp . Body ) . Decode ( & r ) ; err != nil { return err } if r . Response . Result != 1 { return fmt . Errorf ( " \n " , r . Response . Result , r . Response . Message ) } if len ( r . Response . ServerList ) == 0 { return fmt . Errorf ( " \n " ) } sd . servers = r . Response . ServerList sd . isInitialized = true return nil }
Get server list from steam directory and save it for later
Get server list from steam directory and save it for later