gdebug_testdata.go 798 B

1234567891011121314151617181920212223
  1. // Copyright 2019-2020 gf Author(https://github.com/gogf/gf). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gdebug
  7. import (
  8. "path/filepath"
  9. )
  10. // TestDataPath retrieves and returns the testdata path of current package,
  11. // which is used for unit testing cases only.
  12. // The optional parameter <names> specifies the its sub-folders/sub-files,
  13. // which will be joined with current system separator and returned with the path.
  14. func TestDataPath(names ...string) string {
  15. path := CallerDirectory() + string(filepath.Separator) + "testdata"
  16. for _, name := range names {
  17. path += string(filepath.Separator) + name
  18. }
  19. return path
  20. }