當前位置: 首頁>>代碼示例>>Golang>>正文


Golang EncodingBuffer.Rewind方法代碼示例

本文整理匯總了Golang中github.com/pquerna/ffjson/fflib/v1.EncodingBuffer.Rewind方法的典型用法代碼示例。如果您正苦於以下問題:Golang EncodingBuffer.Rewind方法的具體用法?Golang EncodingBuffer.Rewind怎麽用?Golang EncodingBuffer.Rewind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/pquerna/ffjson/fflib/v1.EncodingBuffer的用法示例。


在下文中一共展示了EncodingBuffer.Rewind方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: MarshalJSONBuf

func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"host":`)
	fflib.WriteJsonString(buf, string(mj.Host))
	buf.WriteString(`,"service":`)
	fflib.WriteJsonString(buf, string(mj.Service))
	buf.WriteString(`,"sub_service":`)
	fflib.WriteJsonString(buf, string(mj.SubService))
	buf.WriteString(`,"metric":`)
	fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64)
	if mj.Tags == nil {
		buf.WriteString(`,"tags":null`)
	} else {
		buf.WriteString(`,"tags":{ `)
		for key, value := range mj.Tags {
			fflib.WriteJsonString(buf, key)
			buf.WriteString(`:`)
			fflib.WriteJsonString(buf, string(value))
			buf.WriteByte(',')
		}
		buf.Rewind(1)
		buf.WriteByte('}')
	}
	buf.WriteByte('}')
	return nil
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:29,代碼來源:event_ffjson.go

示例2: MarshalJSONBuf

func (mj *ResponseCountry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{ `)
	if mj.Data != nil {
		if true {
			buf.WriteString(`"Data":`)

			{
				err = mj.Data.MarshalJSONBuf(buf)
				if err != nil {
					return err
				}
			}

			buf.WriteByte(',')
		}
	}
	if len(mj.Error) != 0 {
		buf.WriteString(`"Error":`)
		fflib.WriteJsonString(buf, string(mj.Error))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:wheelcomplex,項目名稱:geoip-service,代碼行數:29,代碼來源:geoip_ffjson.go

示例3: MarshalJSONBuf

func (mj *Error) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{ "error":`)
	fflib.WriteJsonString(buf, string(mj.Code))
	buf.WriteByte(',')
	if len(mj.Description) != 0 {
		buf.WriteString(`"error_description":`)
		fflib.WriteJsonString(buf, string(mj.Description))
		buf.WriteByte(',')
	}
	if len(mj.URI) != 0 {
		buf.WriteString(`"error_uri":`)
		fflib.WriteJsonString(buf, string(mj.URI))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:raiqub,項目名稱:oauth,代碼行數:26,代碼來源:errors_ffjson.go

示例4: MarshalJSONBuf

func (mj *TheCountry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	var scratch fflib.FormatBitsScratch
	_ = scratch
	_ = obj
	_ = err
	buf.WriteString(`{"GeoNameID":`)
	fflib.FormatBits(&scratch, buf, uint64(mj.GeoNameID), 10, false)
	buf.WriteString(`,"IsoCode":`)
	fflib.WriteJsonString(buf, string(mj.IsoCode))
	if mj.Names == nil {
		buf.WriteString(`,"Names":null`)
	} else {
		buf.WriteString(`,"Names":{ `)
		for key, value := range mj.Names {
			fflib.WriteJsonString(buf, key)
			buf.WriteString(`:`)
			fflib.WriteJsonString(buf, string(value))
			buf.WriteByte(',')
		}
		buf.Rewind(1)
		buf.WriteByte('}')
	}
	buf.WriteByte('}')
	return nil
}
開發者ID:wheelcomplex,項目名稱:geoip-service,代碼行數:27,代碼來源:reader_ffjson.go

示例5: MarshalJSONBuf

func (mj *Incident) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"event":`)
	if mj.EventName != nil {
		buf.WriteString(`"`)
		{
			enc := base64.NewEncoder(base64.StdEncoding, buf)
			enc.Write(reflect.Indirect(reflect.ValueOf(mj.EventName)).Bytes())
			enc.Close()
		}
		buf.WriteString(`"`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteString(`,"time":`)
	fflib.FormatBits2(buf, uint64(mj.Time), 10, mj.Time < 0)
	buf.WriteString(`,"id":`)
	fflib.FormatBits2(buf, uint64(mj.Id), 10, mj.Id < 0)
	if mj.Active {
		buf.WriteString(`,"active":true`)
	} else {
		buf.WriteString(`,"active":false`)
	}
	buf.WriteString(`,"escalation":`)
	fflib.WriteJsonString(buf, string(mj.Escalation))
	buf.WriteString(`,"description":`)
	fflib.WriteJsonString(buf, string(mj.Description))
	buf.WriteString(`,"policy":`)
	fflib.WriteJsonString(buf, string(mj.Policy))
	buf.WriteString(`,"status":`)
	fflib.FormatBits2(buf, uint64(mj.Status), 10, mj.Status < 0)
	buf.WriteString(`,"host":`)
	fflib.WriteJsonString(buf, string(mj.Host))
	buf.WriteString(`,"service":`)
	fflib.WriteJsonString(buf, string(mj.Service))
	buf.WriteString(`,"sub_service":`)
	fflib.WriteJsonString(buf, string(mj.SubService))
	buf.WriteString(`,"metric":`)
	fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64)
	if mj.Tags == nil {
		buf.WriteString(`,"tags":null`)
	} else {
		buf.WriteString(`,"tags":{ `)
		for key, value := range mj.Tags {
			fflib.WriteJsonString(buf, key)
			buf.WriteString(`:`)
			fflib.WriteJsonString(buf, string(value))
			buf.WriteByte(',')
		}
		buf.Rewind(1)
		buf.WriteByte('}')
	}
	buf.WriteByte('}')
	return nil
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:58,代碼來源:incident_ffjson.go

示例6: MarshalJSONBuf

func (mj *Entry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	var scratch fflib.FormatBitsScratch
	_ = scratch
	_ = obj
	_ = err
	buf.WriteString(`{ "manufacturer":`)
	fflib.WriteJsonString(buf, string(mj.Manufacturer))
	buf.WriteString(`,"address":`)
	if mj.Address != nil {
		buf.WriteString(`[`)
		for i, v := range mj.Address {
			if i != 0 {
				buf.WriteString(`,`)
			}
			fflib.WriteJsonString(buf, string(v))
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteString(`,"prefix":`)

	{
		obj, err = mj.Prefix.MarshalJSON()
		if err != nil {
			return err
		}
		buf.Write(obj)
	}

	buf.WriteByte(',')
	if len(mj.Country) != 0 {
		buf.WriteString(`"country":`)
		fflib.WriteJsonString(buf, string(mj.Country))
		buf.WriteByte(',')
	}
	if mj.Local != false {
		if mj.Local {
			buf.WriteString(`"local":true`)
		} else {
			buf.WriteString(`"local":false`)
		}
		buf.WriteByte(',')
	}
	if mj.Multicast != false {
		if mj.Multicast {
			buf.WriteString(`"multicast":true`)
		} else {
			buf.WriteString(`"multicast":false`)
		}
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:wheelcomplex,項目名稱:oui,代碼行數:58,代碼來源:entry_ffjson.go

示例7: MarshalJSONBuf

func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{ "type":`)
	fflib.WriteJsonString(buf, string(mj.Type))
	buf.WriteByte(',')
	if len(mj.Username) != 0 {
		buf.WriteString(`"username":`)
		fflib.WriteJsonString(buf, string(mj.Username))
		buf.WriteByte(',')
	}
	if len(mj.Color) != 0 {
		buf.WriteString(`"color":`)
		fflib.WriteJsonString(buf, string(mj.Color))
		buf.WriteByte(',')
	}
	if len(mj.Text) != 0 {
		buf.WriteString(`"text":`)
		fflib.WriteJsonString(buf, string(mj.Text))
		buf.WriteByte(',')
	}
	if mj.TopicID != 0 {
		buf.WriteString(`"topic-id":`)
		fflib.FormatBits2(buf, uint64(mj.TopicID), 10, mj.TopicID < 0)
		buf.WriteByte(',')
	}
	buf.WriteString(`"option-a":`)
	fflib.WriteJsonString(buf, string(mj.OptionA))
	buf.WriteString(`,"option-b":`)
	fflib.WriteJsonString(buf, string(mj.OptionB))
	buf.WriteByte(',')
	if mj.VoteMask != 0 {
		buf.WriteString(`"vote-mask":`)
		fflib.FormatBits2(buf, uint64(mj.VoteMask), 10, false)
		buf.WriteByte(',')
	}
	if len(mj.Error) != 0 {
		buf.WriteString(`"error":`)
		fflib.WriteJsonString(buf, string(mj.Error))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:strawmang,項目名稱:strawmang,代碼行數:51,代碼來源:ffjson_chat.go

示例8: MarshalJSONBuf

func (mj *SubmitOutput) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	var err error
	var obj []byte
	_ = obj
	_ = err
	if mj.Success {
		buf.WriteString(`{ "success":true`)
	} else {
		buf.WriteString(`{ "success":false`)
	}
	buf.WriteByte(',')
	if len(mj.Error) != 0 {
		buf.WriteString(`"error":`)
		fflib.WriteJsonString(buf, string(mj.Error))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:GeenPeil,項目名稱:teken,代碼行數:20,代碼來源:outputtypes_ffjson.go

示例9: MarshalJSONBuf

func (mj *JSONError) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{ `)
	if mj.Status != 0 {
		buf.WriteString(`"status":`)
		fflib.FormatBits2(buf, uint64(mj.Status), 10, mj.Status < 0)
		buf.WriteByte(',')
	}
	if len(mj.Code) != 0 {
		buf.WriteString(`"code":`)
		fflib.WriteJsonString(buf, string(mj.Code))
		buf.WriteByte(',')
	}
	if len(mj.Type) != 0 {
		buf.WriteString(`"type":`)
		fflib.WriteJsonString(buf, string(mj.Type))
		buf.WriteByte(',')
	}
	if len(mj.Message) != 0 {
		buf.WriteString(`"message":`)
		fflib.WriteJsonString(buf, string(mj.Message))
		buf.WriteByte(',')
	}
	if len(mj.MoreInfo) != 0 {
		buf.WriteString(`"moreInfo":`)
		fflib.WriteJsonString(buf, string(mj.MoreInfo))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:raiqub,項目名稱:web,代碼行數:39,代碼來源:jsonerror_ffjson.go

示例10: MarshalJSONBuf

func (mj *TokenResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{ "access_token":`)
	fflib.WriteJsonString(buf, string(mj.AccessToken))
	buf.WriteString(`,"token_type":`)
	fflib.WriteJsonString(buf, string(mj.TokenType))
	buf.WriteByte(',')
	if mj.ExpiresIn != 0 {
		buf.WriteString(`"expires_in":`)
		fflib.FormatBits2(buf, uint64(mj.ExpiresIn), 10, mj.ExpiresIn < 0)
		buf.WriteByte(',')
	}
	if len(mj.RefreshToken) != 0 {
		buf.WriteString(`"refresh_token":`)
		fflib.WriteJsonString(buf, string(mj.RefreshToken))
		buf.WriteByte(',')
	}
	if len(mj.Scope) != 0 {
		buf.WriteString(`"scope":`)
		fflib.WriteJsonString(buf, string(mj.Scope))
		buf.WriteByte(',')
	}
	if len(mj.State) != 0 {
		buf.WriteString(`"state":`)
		fflib.WriteJsonString(buf, string(mj.State))
		buf.WriteByte(',')
	}
	buf.Rewind(1)
	buf.WriteByte('}')
	return nil
}
開發者ID:raiqub,項目名稱:oauth,代碼行數:38,代碼來源:models_ffjson.go

示例11: MarshalJSONBuf


//.........這裏部分代碼省略.........
			fflib.WriteJsonString(buf, string(v.ValueOneLifeMax))
			buf.WriteString(`,"last_save":`)
			fflib.WriteJsonString(buf, string(v.LastSave))
			buf.WriteByte('}')
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteString(`,"stat_history":`)
	if mj.Stats.StatHistory != nil {
		buf.WriteString(`[`)
		for i, v := range mj.Stats.StatHistory {
			if i != 0 {
				buf.WriteString(`,`)
			}
			/* Inline struct. type=struct { Name string "json:\"stat_name\""; AllTime string "json:\"all_time\""; OneLifeMax string "json:\"one_life_max\""; Day map[string]string "json:\"day\""; Month map[string]string "json:\"Month\""; Week map[string]string "json:\"Week\"" } kind=struct */
			buf.WriteString(`{ "stat_name":`)
			fflib.WriteJsonString(buf, string(v.Name))
			buf.WriteString(`,"all_time":`)
			fflib.WriteJsonString(buf, string(v.AllTime))
			buf.WriteString(`,"one_life_max":`)
			fflib.WriteJsonString(buf, string(v.OneLifeMax))
			if v.Day == nil {
				buf.WriteString(`,"day":null`)
			} else {
				buf.WriteString(`,"day":{ `)
				for key, value := range v.Day {
					fflib.WriteJsonString(buf, key)
					buf.WriteString(`:`)
					fflib.WriteJsonString(buf, string(value))
					buf.WriteByte(',')
				}
				buf.Rewind(1)
				buf.WriteByte('}')
			}
			if v.Month == nil {
				buf.WriteString(`,"Month":null`)
			} else {
				buf.WriteString(`,"Month":{ `)
				for key, value := range v.Month {
					fflib.WriteJsonString(buf, key)
					buf.WriteString(`:`)
					fflib.WriteJsonString(buf, string(value))
					buf.WriteByte(',')
				}
				buf.Rewind(1)
				buf.WriteByte('}')
			}
			if v.Week == nil {
				buf.WriteString(`,"Week":null`)
			} else {
				buf.WriteString(`,"Week":{ `)
				for key, value := range v.Week {
					fflib.WriteJsonString(buf, key)
					buf.WriteString(`:`)
					fflib.WriteJsonString(buf, string(value))
					buf.WriteByte(',')
				}
				buf.Rewind(1)
				buf.WriteByte('}')
			}
			buf.WriteByte('}')
		}
		buf.WriteString(`]`)
	} else {
開發者ID:THUNDERGROOVE,項目名稱:census,代碼行數:67,代碼來源:character_ffjson.go


注:本文中的github.com/pquerna/ffjson/fflib/v1.EncodingBuffer.Rewind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。