MCPcopy Create free account
hub / github.com/goadesign/goa / convertToString

Function convertToString

codegen/example/server_data.go:343–372  ·  view source on GitHub ↗

convertToString converts primitive type to a string.

(vals ...any)

Source from the content-addressed store, hash-verified

341
342// convertToString converts primitive type to a string.
343func convertToString(vals ...any) []string {
344 str := make([]string, len(vals))
345 for i, v := range vals {
346 switch t := v.(type) {
347 case bool:
348 str[i] = strconv.FormatBool(t)
349 case int:
350 str[i] = strconv.Itoa(t)
351 case int32:
352 str[i] = strconv.FormatInt(int64(t), 10)
353 case int64:
354 str[i] = strconv.FormatInt(t, 10)
355 case uint:
356 str[i] = strconv.FormatUint(uint64(t), 10)
357 case uint32:
358 str[i] = strconv.FormatUint(uint64(t), 10)
359 case uint64:
360 str[i] = strconv.FormatUint(t, 10)
361 case float32:
362 str[i] = strconv.FormatFloat(float64(t), 'f', -1, 32)
363 case float64:
364 str[i] = strconv.FormatFloat(t, 'f', -1, 64)
365 case string:
366 str[i] = t
367 default:
368 panic(fmt.Sprintf("invalid value type %q to convert to string", t))
369 }
370 }
371 return str
372}
373
374func newHTTPTransport() *TransportData {
375 return &TransportData{Type: TransportHTTP, Name: "HTTP"}

Callers 1

buildHostDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected