MCPcopy
hub / github.com/kashav/fsql / hash

Method hash

transform/format.go:117–137  ·  view source on GitHub ↗

hash applies the provided hash algorithm h with ComputeHash.

(h hash.Hash)

Source from the content-addressed store, hash-verified

115
116// hash applies the provided hash algorithm h with ComputeHash.
117func (p *FormatParams) hash(h hash.Hash) (interface{}, error) {
118 var (
119 err error
120 n int
121 result interface{}
122 )
123
124 if len(p.Args) == 0 || p.Args[0] == "" {
125 n = defaultHashLength
126 } else if strings.ToUpper(p.Args[0]) == "FULL" {
127 n = -1
128 } else if n, err = strconv.Atoi(p.Args[0]); err != nil {
129 return nil, err
130 }
131
132 if result, err = ComputeHash(p.Info, p.Path, h); err != nil {
133 return nil, err
134 }
135
136 return truncate(result.(string), n), nil
137}
138
139// DefaultFormatValue returns the default format value for the provided
140// attribute attr based on path and info.

Callers 1

FormatFunction · 0.45

Calls 2

ComputeHashFunction · 0.85
truncateFunction · 0.85

Tested by

no test coverage detected