remove.go 505 B

1234567891011121314151617181920212223242526
  1. package pb
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "strings"
  6. "testing"
  7. )
  8. const filename = "./roleUser.pb.go"
  9. func TestRemoveTag(t *testing.T) {
  10. fileData, err := ioutil.ReadFile(filename)
  11. if err != nil {
  12. fmt.Printf("ReadFile err: %v\n", err)
  13. return
  14. }
  15. data := strings.ReplaceAll(string(fileData), ",omitempty", "")
  16. fileData = []byte(data)
  17. err = ioutil.WriteFile(filename, fileData, 0644)
  18. if err != nil {
  19. fmt.Printf("WriteFile err: %v\n", err)
  20. return
  21. }
  22. fmt.Println("TestRemoveTag successfully")
  23. }