swag.go 371 B

12345678910111213141516171819202122
  1. package initialize
  2. import (
  3. "bytes"
  4. "fmt"
  5. "os"
  6. "os/exec"
  7. )
  8. // SwagInit 初始化swag http://localhost:8000/swagger/index.html
  9. func SwagInit() {
  10. cmd := exec.Command("swag", "init")
  11. fmt.Println("Cmd", cmd.Args)
  12. var out bytes.Buffer
  13. cmd.Stdout = &out
  14. cmd.Stderr = os.Stderr
  15. if err := cmd.Start(); err != nil {
  16. fmt.Println(err)
  17. }
  18. fmt.Println(out.String())
  19. }