go.go 306 B

123456789101112131415161718192021
  1. package yatest
  2. import (
  3. "os"
  4. )
  5. func PrepareGOPATH() error {
  6. return preparePath("GOPATH")
  7. }
  8. func PrepareGOCACHE() error {
  9. return preparePath("GOCACHE")
  10. }
  11. func preparePath(name string) error {
  12. p, err := os.MkdirTemp(WorkPath(""), "name")
  13. if err != nil {
  14. return err
  15. }
  16. return os.Setenv(name, p)
  17. }