vet.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. o=_output/_vet/
  3. ALL="$o/vet.txt"
  4. typi() {
  5. local typ="$1"
  6. local fna="$o/vet_$(echo "$typ" | sed -r -e "s/[^a-zA-Z0-9]+/_/g").txt"
  7. grep -F "$typ" "$UNKNOWN" >"$fna"
  8. grep -F -v "$typ" "$UNKNOWN" >""$INTERMEDIATE""
  9. cp "$INTERMEDIATE" "$UNKNOWN"
  10. rm -f "$INTERMEDIATE"
  11. if [ ! -s "$fna" ]; then
  12. rm -f "$fna"
  13. fi
  14. }
  15. typ() {
  16. local UNKNOWN=$o/vet0.txt
  17. local INTERMEDIATE=$o/vet1.txt
  18. cp "$ALL" "$UNKNOWN"
  19. typi "unreachable code"
  20. typi "composite literal uses unkeyed fields"
  21. typi "repeats json tag"
  22. typi "bad syntax for struct tag key"
  23. typi "bad syntax for struct tag value"
  24. typi "pairs not separated by spaces"
  25. typi "bad syntax for struct tag pair"
  26. }
  27. gen() {
  28. rm -rf "$o"
  29. mkdir -p "$o"
  30. go vet ./... 2>"$ALL"
  31. typ
  32. ls -l $o/
  33. }
  34. chki() {
  35. local typ="$1"
  36. if grep -F "$typ" "$ALL"; then
  37. exit 1
  38. fi
  39. }
  40. chk() {
  41. chki "unreachable code"
  42. chki "composite literal uses unkeyed fields"
  43. : chki "repeats json tag"
  44. : chki "bad syntax for struct tag key"
  45. : chki "bad syntax for struct tag value"
  46. chki "pairs not separated by spaces"
  47. chki "bad syntax for struct tag pair"
  48. }
  49. "$@"