MCPcopy
hub / github.com/nats-io/nats.go / GetString

Method GetString

object.go:869–881  ·  view source on GitHub ↗

GetString is a convenience function to pull an object from this object store and return it as a string.

(name string, opts ...GetObjectOpt)

Source from the content-addressed store, hash-verified

867
868// GetString is a convenience function to pull an object from this object store and return it as a string.
869func (obs *obs) GetString(name string, opts ...GetObjectOpt) (string, error) {
870 result, err := obs.Get(name, opts...)
871 if err != nil {
872 return _EMPTY_, err
873 }
874 defer result.Close()
875
876 var b bytes.Buffer
877 if _, err := b.ReadFrom(result); err != nil {
878 return _EMPTY_, err
879 }
880 return b.String(), nil
881}
882
883// PutFile is convenience function to put a file into an object store.
884func (obs *obs) PutFile(file string, opts ...ObjectOpt) (*ObjectInfo, error) {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected