Files
server/test/tmpdir.go
renovate[bot] a0bad7bd5a chore(deps): update bump go dependencies (#751)
* chore(deps): update bump go dependencies

* Update golangci-lint

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* Update golangci config to reflect new format

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

* remove deprecated ioutil package

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>

---------

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: eternal-flame-AD <yume@yumechi.jp>
2025-01-17 05:51:08 +00:00

28 lines
552 B
Go

package test
import (
"os"
"path"
)
// TmpDir is a handler to temporary directory.
type TmpDir struct {
path string
}
// Path returns the path to the temporary directory joined by the elements provided.
func (c TmpDir) Path(elem ...string) string {
return path.Join(append([]string{c.path}, elem...)...)
}
// Clean removes the TmpDir.
func (c TmpDir) Clean() error {
return os.RemoveAll(c.path)
}
// NewTmpDir returns a new handle to a tmp dir.
func NewTmpDir(prefix string) TmpDir {
dir, _ := os.MkdirTemp("", prefix)
return TmpDir{dir}
}