api/worksheet.go
func (a *API) FetchWorksheet(cid CIDType) (*Worksheet, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid worksheet CID [none]")
	}

	worksheetCID := string(*cid)

	matched, err := regexp.MatchString(config.WorksheetCIDRegex, worksheetCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid worksheet CID [%s]", worksheetCID)
	}

	result, err := a.Get(string(*cid))
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch worksheet, received JSON: %s", string(result))
	}

	worksheet := new(Worksheet)
	if err := json.Unmarshal(result, worksheet); err != nil {
		return nil, err
	}

	return worksheet, nil
}
func (a *API) FetchWorksheet(cid CIDType) (*Worksheet, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid worksheet CID [none]")
	}

	worksheetCID := string(*cid)

	matched, err := regexp.MatchString(config.WorksheetCIDRegex, worksheetCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid worksheet CID [%s]", worksheetCID)
	}

	result, err := a.Get(string(*cid))
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch worksheet, received JSON: %s", string(result))
	}

	worksheet := new(Worksheet)
	if err := json.Unmarshal(result, worksheet); err != nil {
		return nil, err
	}

	return worksheet, nil
}
func ( a * API ) FetchWorksheet ( cid CIDType ) ( * Worksheet , error ) { if cid == nil || * cid == " " { return nil , fmt . Errorf ( " " ) } worksheetCID := string ( * cid ) matched , err := regexp . MatchString ( config . WorksheetCIDRegex , worksheetCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , worksheetCID ) } result , err := a . Get ( string ( * cid ) ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( result ) ) } worksheet := new ( Worksheet ) if err := json . Unmarshal ( result , worksheet ) ; err != nil { return nil , err } return worksheet , nil }
// FetchWorksheet retrieves worksheet with passed cid.
FetchWorksheet retrieves worksheet with passed cid .