Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/bin/bash
  2. lastfile=""
  3. cnt=0
  4.  
  5. golint ./... | egrep ' exported (function|method|type) ' | while read line; do
  6. echo "-> "$line
  7.  
  8. file=`echo $line | cut -d: -f1`
  9. if [ "$file" = "$lastfile" ]; then
  10. cnt=$((cnt+1))
  11. else
  12. cnt=0
  13. fi
  14.  
  15. lineno=`echo $line | cut -d: -f2`
  16. lineno=$((lineno + cnt))
  17. if [[ $line =~ ": exported type" ]]; then
  18. func=`echo $line | cut -d' ' -f4`
  19. gsed -i -e "${lineno}i //${func} ..." $file
  20. echo "update"
  21. elif [[ $line =~ ": exported function" ]]; then
  22. func=`echo $line | cut -d' ' -f4`
  23. gsed -i -e "${lineno}i //${func} ..." $file
  24. echo "update"
  25. elif [[ $line =~ ": comment on exported function" ]]; then
  26. func=`echo $line | cut -d' ' -f6`
  27. gsed -i -e "${lineno}i //${func} ..." $file
  28. echo "update"
  29. elif [[ $line =~ ": exported method" ]]; then
  30. pkg=`echo $line | cut -d' ' -f4`
  31. method=`echo $pkg | cut -d. -f2`
  32. gsed -i -e "${lineno}i //${method} ..." $file
  33. echo "update"
  34. else
  35. cnt=$((cnt-1))
  36. fi
  37.  
  38. lastfile=$file
  39. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement