当前位置: 首页>>代码示例>>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;未经允许,请勿转载。