MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / String

Method String

app/controlplane/pkg/data/ent/ent.go:363–377  ·  view source on GitHub ↗

String returns a single string from a selector. It is only allowed when selecting one field.

(ctx context.Context)

Source from the content-addressed store, hash-verified

361
362// String returns a single string from a selector. It is only allowed when selecting one field.
363func (s *selector) String(ctx context.Context) (_ string, err error) {
364 var v []string
365 if v, err = s.Strings(ctx); err != nil {
366 return
367 }
368 switch len(v) {
369 case 1:
370 return v[0], nil
371 case 0:
372 err = &NotFoundError{s.label}
373 default:
374 err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
375 }
376 return
377}
378
379// StringX is like String, but panics if an error occurs.
380func (s *selector) StringX(ctx context.Context) string {

Callers 1

StringXMethod · 0.95

Calls 1

StringsMethod · 0.95

Tested by

no test coverage detected