nginx_test.go 334 B

1234567891011121314151617181920
  1. package test
  2. import (
  3. "fmt"
  4. "log"
  5. "os/exec"
  6. "regexp"
  7. "testing"
  8. )
  9. func TestGetNginx(t *testing.T) {
  10. out, err := exec.Command("nginx", "-V").CombinedOutput()
  11. if err != nil {
  12. log.Fatal(err)
  13. }
  14. fmt.Printf("%s\n", out)
  15. r, _ := regexp.Compile("--conf-path=(.*)/(.*.conf)")
  16. fmt.Println(r.FindStringSubmatch(string(out))[1])
  17. }