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


Golang strconv.AppendInt函數代碼示例

本文整理匯總了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
}
開發者ID:TGenNorth,項目名稱:NASP,代碼行數:30,代碼來源:matrix.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:27,代碼來源:en_SC.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:36,代碼來源:en_SC.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:27,代碼來源:be_BY.go

示例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)
	}
}
開發者ID:ZhiephieCook,項目名稱:gh-ost,代碼行數:34,代碼來源:resultset_helper.go

示例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
}
開發者ID:Civil,項目名稱:carbonapi,代碼行數:33,代碼來源:metricdata.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:30,代碼來源:ta_MY.go

示例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),
	}
}
開發者ID:MStoykov,項目名稱:jsonutils,代碼行數:37,代碼來源:syntax_error.go

示例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
}
開發者ID:varstr,項目名稱:gomc,代碼行數:33,代碼來源:encoding.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:27,代碼來源:bg_BG.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:29,代碼來源:uz_Latn_UZ.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:35,代碼來源:zh_Hans_MO.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:35,代碼來源:fr_BE.go

示例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)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:28,代碼來源:vi_VN.go

示例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)
}
開發者ID:YaSuenag,項目名稱:hsbeat,代碼行數:32,代碼來源:util.go


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