MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ReadFile

Function ReadFile

pkg/i18n/i18n.go:136–150  ·  view source on GitHub ↗

ReadFile reads the descriptors from a file.

(filename string)

Source from the content-addressed store, hash-verified

134
135// ReadFile reads the descriptors from a file.
136func ReadFile(filename string) (MessageDescriptorMap, error) {
137 bytes, err := os.ReadFile(filename)
138 if err != nil {
139 return nil, err
140 }
141 descriptors := make(MessageDescriptorMap)
142 err = json.Unmarshal(bytes, &descriptors)
143 if err != nil {
144 return nil, err
145 }
146 for id, descriptor := range descriptors {
147 descriptor.id = id
148 }
149 return descriptors, nil
150}
151
152// MarshalJSON marshals the descriptors to JSON.
153func (m MessageDescriptorMap) MarshalJSON() ([]byte, error) {

Callers 2

mainFunction · 0.92
TestI18NFunction · 0.92

Calls 2

ReadFileMethod · 0.65
UnmarshalMethod · 0.65

Tested by 1

TestI18NFunction · 0.74