export Minify
(cOptions *C.MinifyOptions, cResult *C.MinifyResult)
| 223 | |
| 224 | //export Minify |
| 225 | func Minify(cOptions *C.MinifyOptions, cResult *C.MinifyResult) { |
| 226 | opts, err := parseOptions(cOptions) |
| 227 | if err != nil { |
| 228 | setResult(cResult, err, "") |
| 229 | return |
| 230 | } |
| 231 | |
| 232 | dataBytes := []byte(opts.Data) |
| 233 | if len(dataBytes) == 0 { |
| 234 | setResult(cResult, errors.New("data is required"), "") |
| 235 | return |
| 236 | } |
| 237 | mediatype, err := resolveType(opts.Type) |
| 238 | if err != nil { |
| 239 | setResult(cResult, err, "") |
| 240 | return |
| 241 | } |
| 242 | if mediatype == "" { |
| 243 | setResult(cResult, errors.New("type is required"), "") |
| 244 | return |
| 245 | } |
| 246 | |
| 247 | m, err := newMinifier(opts) |
| 248 | if err != nil { |
| 249 | setResult(cResult, err, "") |
| 250 | return |
| 251 | } |
| 252 | |
| 253 | outBuf := buffer.NewWriter(make([]byte, 0, len(dataBytes))) |
| 254 | if err := m.Minify(mediatype, outBuf, buffer.NewReader(dataBytes)); err != nil { |
| 255 | setResult(cResult, err, "") |
| 256 | return |
| 257 | } |
| 258 | |
| 259 | setResult(cResult, nil, string(outBuf.Bytes())) |
| 260 | } |
| 261 | |
| 262 | //export FreeCString |
| 263 | func FreeCString(ptr unsafe.Pointer) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…