10 examples of 'golang string builder' in Go

Every line of 'golang string builder' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
117func (_String__Prototype) NewBuilder() ipld.NodeBuilder {
118 var nb _String__Builder
119 nb.Reset()
120 return &nb
121}
51func (this *JSONArray) buildString(sb *strings.Builder) {
52 sb.WriteByte('[')
53 for idx, v := range this.data {
54 if idx > 0 {
55 sb.WriteByte(',')
56 }
57 v.buildString(sb)
58 }
59 sb.WriteByte(']')
60}
13func (this *JSONString) buildString(sb *strings.Builder) {
14 sb.WriteString(this.String())
15}
291func (f *Formatter) build(s string) {
292 f.builder.WriteString(s)
293}
54func (n Time) buildString(b *strings.Builder) {
55 if 0 < len(TimeWrap) {
56 b.WriteString(`{"`)
57 b.WriteString(TimeWrap)
58 b.WriteString(`":`)
59 }
60 switch TimeFormat {
61 case "", "nano":
62 b.WriteString(strconv.FormatInt(time.Time(n).UnixNano(), 10))
63 case "second":
64 // Decimal format but float is not accurate enough so build the output
65 // in two parts.
66 nano := time.Time(n).UnixNano()
67 secs := nano / int64(time.Second)
68 if 0 < nano {
69 b.WriteString(fmt.Sprintf("%d.%09d", secs, nano-(secs*int64(time.Second))))
70 } else {
71 b.WriteString(fmt.Sprintf("%d.%09d", secs, -nano+(secs*int64(time.Second))))
72 }
73 default:
74 b.WriteString(`"`)
75 b.WriteString(time.Time(n).Format(TimeFormat))
76 b.WriteString(`"`)
77 }
78 if 0 < len(TimeWrap) {
79 b.WriteString("}")
80 }
81}
65func (builder GORMTagBuilder) Build(column *Column) string {
66 options := []string{}
67 options = append(options, fmt.Sprintf("column:%s", column.Name))
68 options = append(options, fmt.Sprintf("type:%s", strings.ToLower(column.Type.DBType())))
69
70 if column.Type.IsPrimaryKey {
71 options = append(options, "primary_key")
72 }
73
74 if column.Type.IsNullable {
75 options = append(options, "null")
76 } else {
77 options = append(options, "not null")
78 }
79
80 if size := column.Type.CharMaxLength; size > 0 {
81 options = append(options, fmt.Sprintf("size:%d", size))
82 }
83
84 if precision := column.Type.Precision; precision > 0 {
85 options = append(options, fmt.Sprintf("precision:%d", precision))
86 }
87
88 return fmt.Sprintf("gorm:\"%s\"", strings.Join(options, ";"))
89}
134func (q *queryBuilderImpl) Build() string {
135 return q.builder.String()
136}
24func(b *BaseMessageBuilder)Build(messages ... string) string{
25 return strings.Join(messages,",")
26}
15func (locking Locking) Build(builder Builder) {
16 builder.WriteString(locking.Strength)
17 if locking.Table.Name != "" {
18 builder.WriteString(" OF ")
19 builder.WriteQuoted(locking.Table)
20 }
21
22 if locking.Options != "" {
23 builder.WriteByte(' ')
24 builder.WriteString(locking.Options)
25 }
26}
217func (sb *SelectBuilder) BuilderAs(builder Builder, alias string) string {
218 return fmt.Sprintf("(%s) AS %s", sb.Var(builder), alias)
219}

Related snippets