jsonlint.go 411 B

1234567891011121314151617181920212223242526
  1. package jsonlint
  2. import (
  3. "encoding/json"
  4. "io"
  5. "go-common/app/admin/main/config/pkg/lint"
  6. )
  7. const filetype = "json"
  8. type jsonlint struct{}
  9. func (jsonlint) Lint(r io.Reader) lint.Error {
  10. var v interface{}
  11. dec := json.NewDecoder(r)
  12. err := dec.Decode(&v)
  13. if err == nil {
  14. return nil
  15. }
  16. return lint.Error{{Line: -1, Message: err.Error()}}
  17. }
  18. func init() {
  19. lint.RegisterLinter(filetype, jsonlint{})
  20. }