MCPcopy Index your code
hub / github.com/apache/casbin / write

Method write

config/config.go:169–186  ·  view source on GitHub ↗
(section string, lineNum int, b *bytes.Buffer)

Source from the content-addressed store, hash-verified

167}
168
169func (c *Config) write(section string, lineNum int, b *bytes.Buffer) error {
170 if b.Len() <= 0 {
171 return nil
172 }
173
174 optionVal := bytes.SplitN(b.Bytes(), []byte{'='}, 2)
175 if len(optionVal) != 2 {
176 return fmt.Errorf("parse the content error : line %d , %s = ? ", lineNum, optionVal[0])
177 }
178 option := bytes.TrimSpace(optionVal[0])
179 value := bytes.TrimSpace(optionVal[1])
180 c.AddConfig(section, string(option), string(value))
181
182 // flush buffer after adding
183 b.Reset()
184
185 return nil
186}
187
188// Bool lookups up the value using the provided key and converts the value to a bool.
189func (c *Config) Bool(key string) (bool, error) {

Callers 1

parseBufferMethod · 0.95

Calls 1

AddConfigMethod · 0.95

Tested by

no test coverage detected