本文整理汇总了Golang中strconv.AppendInt函数的典型用法代码示例。如果您正苦于以下问题:Golang AppendInt函数的具体用法?Golang AppendInt怎么用?Golang AppendInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AppendInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: vcfFormat
func (l *line) vcfFormat(contigName string, positionNum int64, position *Position) []byte {
l.buffer = l.buffer[:0]
// #CHROM
l.buffer = append(l.buffer, contigName...)
l.buffer = append(l.buffer, '\t')
// POS
l.buffer = strconv.AppendInt(l.buffer, int64(positionNum), 10)
// ID
l.buffer = append(l.buffer, '\t', '.', '\t')
// REF
l.buffer = append(l.buffer, position.callStr[0], '\t')
// QUAL
l.buffer = append(l.buffer, '\t', '.', '\t')
// FILTER
if position.isAllCalled && position.isAllPassCoverage && position.isAllPassProportion {
l.buffer = append(l.buffer, 'P', 'A', 'S', 'S', '\t')
} else {
l.buffer = append(l.buffer, 'F', 'A', 'I', 'L', '\t')
}
// INFO
l.buffer = append(l.buffer, 'A', 'N', '=')
//l.buffer = strconv.AppendInt(l.buffer, len(alts), 10)
l.buffer = append(l.buffer, ';', 'N', 'S', '=')
l.buffer = strconv.AppendInt(l.buffer, position.calledReference+position.calledSnp, 10)
// FORMAT
l.buffer = append(l.buffer, '\t', 'G', 'T', ':', 'F', 'T', '\t')
// sample analysis columns
//l.vcfSampleAnalysisColumns(position.pattern, position.callWasMade, position.passedDepthFilter, position.passedProportionFilter)
return l.buffer
}
示例2: FmtTimeMedium
// FmtTimeMedium returns the medium time representation of 't' for 'en_SC'
func (en *en_SC) FmtTimeMedium(t time.Time) string {
b := make([]byte, 0, 32)
if t.Hour() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Hour()), 10)
b = append(b, en.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, en.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
return string(b)
}
示例3: FmtTimeFull
// FmtTimeFull returns the full time representation of 't' for 'en_SC'
func (en *en_SC) FmtTimeFull(t time.Time) string {
b := make([]byte, 0, 32)
if t.Hour() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Hour()), 10)
b = append(b, en.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, en.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20}...)
tz, _ := t.Zone()
if btz, ok := en.timezones[tz]; ok {
b = append(b, btz...)
} else {
b = append(b, tz...)
}
return string(b)
}
示例4: FmtTimeMedium
// FmtTimeMedium returns the medium time representation of 't' for 'be_BY'
func (be *be_BY) FmtTimeMedium(t time.Time) string {
b := make([]byte, 0, 32)
if t.Hour() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Hour()), 10)
b = append(b, []byte{0x2e}...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, []byte{0x2e}...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
return string(b)
}
示例5: formatTextValue
func formatTextValue(value interface{}) ([]byte, error) {
switch v := value.(type) {
case int8:
return strconv.AppendInt(nil, int64(v), 10), nil
case int16:
return strconv.AppendInt(nil, int64(v), 10), nil
case int32:
return strconv.AppendInt(nil, int64(v), 10), nil
case int64:
return strconv.AppendInt(nil, int64(v), 10), nil
case int:
return strconv.AppendInt(nil, int64(v), 10), nil
case uint8:
return strconv.AppendUint(nil, uint64(v), 10), nil
case uint16:
return strconv.AppendUint(nil, uint64(v), 10), nil
case uint32:
return strconv.AppendUint(nil, uint64(v), 10), nil
case uint64:
return strconv.AppendUint(nil, uint64(v), 10), nil
case uint:
return strconv.AppendUint(nil, uint64(v), 10), nil
case float32:
return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
case float64:
return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
case []byte:
return v, nil
case string:
return hack.Slice(v), nil
default:
return nil, errors.Errorf("invalid type %T", value)
}
}
示例6: MarshalRaw
func MarshalRaw(results []*MetricData) []byte {
var b []byte
for _, r := range results {
b = append(b, r.GetName()...)
b = append(b, ',')
b = strconv.AppendInt(b, int64(r.GetStartTime()), 10)
b = append(b, ',')
b = strconv.AppendInt(b, int64(r.GetStopTime()), 10)
b = append(b, ',')
b = strconv.AppendInt(b, int64(r.GetStepTime()), 10)
b = append(b, '|')
var comma bool
for i, v := range r.Values {
if comma {
b = append(b, ',')
}
comma = true
if r.IsAbsent[i] {
b = append(b, "None"...)
} else {
b = strconv.AppendFloat(b, v, 'f', -1, 64)
}
}
b = append(b, '\n')
}
return b
}
示例7: FmtTimeShort
// FmtTimeShort returns the short time representation of 't' for 'ta_MY'
func (ta *ta_MY) FmtTimeShort(t time.Time) string {
b := make([]byte, 0, 32)
if t.Hour() < 12 {
b = append(b, ta.periodsAbbreviated[0]...)
} else {
b = append(b, ta.periodsAbbreviated[1]...)
}
b = append(b, []byte{0x20}...)
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, ta.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
return string(b)
}
示例8: NewSyntaxError
// NewSyntaxError returns a SyntaxError wrapping around json.SyntaxError.
// The provided jsonContents should be the input that produced the error
// the contextSize is the number of lines around the to be printed as well
//
// Notice: in the message all the tabs are replaced by a single space
func NewSyntaxError(original *json.SyntaxError, jsonContents []byte, contextSize int64) *SyntaxError {
if len(jsonContents) == 0 {
return &SyntaxError{
original: original,
// replace the tabs so that the offset is correct
msg: strings.Join(
[]string{"with no json contents got :", original.Error()}, ""),
}
}
context, offsetOnLine, nextLineOffset := getContextAroundOffset(jsonContents, original.Offset, contextSize)
var errorShowingLineBuffer = make([][]byte, 0, 9)
errorShowingLineBuffer = append(errorShowingLineBuffer, replaceTabsWithSpace(context[:nextLineOffset]))
errorShowingLineBuffer = append(errorShowingLineBuffer, []byte{newline})
if offsetOnLine > 2 {
errorShowingLineBuffer = append(errorShowingLineBuffer, bytes.Repeat([]byte{'-'}, int(offsetOnLine-2)))
}
var lineNumber = bytes.Count(jsonContents[:original.Offset], []byte{newline}) + 1
errorShowingLineBuffer = append(errorShowingLineBuffer, strconv.AppendInt([]byte("^ on line "), int64(lineNumber), 10))
errorShowingLineBuffer = append(errorShowingLineBuffer, strconv.AppendInt([]byte(" column "), offsetOnLine, 10))
errorShowingLineBuffer = append(errorShowingLineBuffer, []byte(" got :"))
errorShowingLineBuffer = append(errorShowingLineBuffer, []byte(original.Error()))
errorShowingLineBuffer = append(errorShowingLineBuffer, replaceTabsWithSpace(context[nextLineOffset:]))
var msg = bytes.Join(errorShowingLineBuffer, []byte{})
return &SyntaxError{
original: original,
// replace the tabs so that the offset is correct
msg: string(msg),
}
}
示例9: encodeDefault
func encodeDefault(object interface{}) (buffer []byte, err error) {
switch object.(type) {
case bool:
buffer = strconv.AppendBool(buffer, object.(bool))
case int:
buffer = strconv.AppendInt(buffer, int64(object.(int)), _NUMERIC_BASE)
case int8:
buffer = strconv.AppendInt(buffer, int64(object.(int8)), _NUMERIC_BASE)
case int16:
buffer = strconv.AppendInt(buffer, int64(object.(int16)), _NUMERIC_BASE)
case int32:
buffer = strconv.AppendInt(buffer, int64(object.(int32)), _NUMERIC_BASE)
case int64:
buffer = strconv.AppendInt(buffer, object.(int64), _NUMERIC_BASE)
case uint:
buffer = strconv.AppendUint(buffer, uint64(object.(uint)), _NUMERIC_BASE)
case uint8:
buffer = strconv.AppendUint(buffer, uint64(object.(uint8)), _NUMERIC_BASE)
case uint16:
buffer = strconv.AppendUint(buffer, uint64(object.(uint16)), _NUMERIC_BASE)
case uint32:
buffer = strconv.AppendUint(buffer, uint64(object.(uint32)), _NUMERIC_BASE)
case uint64:
buffer = strconv.AppendUint(buffer, object.(uint64), _NUMERIC_BASE)
case string:
buffer = []byte(object.(string))
case []byte:
buffer = object.([]byte)
default:
err = errors.New("Invalid object for default encode")
}
return
}
示例10: FmtDateShort
// FmtDateShort returns the short date representation of 't' for 'bg_BG'
func (bg *bg_BG) FmtDateShort(t time.Time) string {
b := make([]byte, 0, 32)
b = strconv.AppendInt(b, int64(t.Day()), 10)
b = append(b, []byte{0x2e}...)
if t.Month() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Month()), 10)
b = append(b, []byte{0x2e}...)
if t.Year() > 9 {
b = append(b, strconv.Itoa(t.Year())[2:]...)
} else {
b = append(b, strconv.Itoa(t.Year())[1:]...)
}
b = append(b, []byte{0x20, 0xd0, 0xb3}...)
b = append(b, []byte{0x2e}...)
return string(b)
}
示例11: FmtTimeLong
// FmtTimeLong returns the long time representation of 't' for 'uz_Latn_UZ'
func (uz *uz_Latn_UZ) FmtTimeLong(t time.Time) string {
b := make([]byte, 0, 32)
b = strconv.AppendInt(b, int64(t.Hour()), 10)
b = append(b, uz.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, uz.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20, 0x28}...)
tz, _ := t.Zone()
b = append(b, tz...)
b = append(b, []byte{0x29}...)
return string(b)
}
示例12: FmtTimeMedium
// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_MO'
func (zh *zh_Hans_MO) FmtTimeMedium(t time.Time) string {
b := make([]byte, 0, 32)
if t.Hour() < 12 {
b = append(b, zh.periodsAbbreviated[0]...)
} else {
b = append(b, zh.periodsAbbreviated[1]...)
}
h := t.Hour()
if h > 12 {
h -= 12
}
b = strconv.AppendInt(b, int64(h), 10)
b = append(b, zh.timeSeparator...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, zh.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
return string(b)
}
示例13: FmtTimeFull
// FmtTimeFull returns the full time representation of 't' for 'fr_BE'
func (fr *fr_BE) FmtTimeFull(t time.Time) string {
b := make([]byte, 0, 32)
b = strconv.AppendInt(b, int64(t.Hour()), 10)
b = append(b, []byte{0x20, 0x68}...)
b = append(b, []byte{0x20}...)
if t.Minute() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, []byte{0x20, 0x6d, 0x69, 0x6e}...)
b = append(b, []byte{0x20}...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20, 0x73}...)
b = append(b, []byte{0x20}...)
tz, _ := t.Zone()
if btz, ok := fr.timezones[tz]; ok {
b = append(b, btz...)
} else {
b = append(b, tz...)
}
return string(b)
}
示例14: FmtDateLong
// FmtDateLong returns the long date representation of 't' for 'vi_VN'
func (vi *vi_VN) FmtDateLong(t time.Time) string {
b := make([]byte, 0, 32)
b = append(b, []byte{0x4e, 0x67, 0xc3, 0xa0, 0x79}...)
b = append(b, []byte{0x20}...)
if t.Day() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Day()), 10)
b = append(b, []byte{0x20, 0x74, 0x68, 0xc3, 0xa1, 0x6e, 0x67}...)
b = append(b, []byte{0x20}...)
if t.Month() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Month()), 10)
b = append(b, []byte{0x20, 0x6e, 0xc4, 0x83, 0x6d}...)
b = append(b, []byte{0x20}...)
b = strconv.AppendInt(b, int64(t.Year()), 10)
return string(b)
}
示例15: appendPadded
func appendPadded(bs []byte, i int, sz int) []byte {
if i < 0 {
bs = append(bs, '-')
i = -i
}
if i < 10 {
for ; sz > 1; sz-- {
bs = append(bs, '0')
}
return append(bs, byte(i)+'0')
}
if i < 100 {
for ; sz > 2; sz-- {
bs = append(bs, '0')
}
return strconv.AppendInt(bs, int64(i), 10)
}
digits := 0
if i < 1000 {
digits = 3
} else if i < 10000 {
digits = 4
} else {
digits = int(math.Log10(float64(i))) + 1
}
for ; sz > digits; sz-- {
bs = append(bs, '0')
}
return strconv.AppendInt(bs, int64(i), 10)
}