mod.go 456 B

1234567891011121314151617181920212223
  1. // Copyright 2025 BackendServerTemplate Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package modutils
  5. import (
  6. "runtime/debug"
  7. "strings"
  8. )
  9. var ModPath = ""
  10. var IsGitHub bool = false
  11. func init() {
  12. info, ok := debug.ReadBuildInfo()
  13. if !ok {
  14. panic("read build info failed")
  15. }
  16. ModPath = info.Main.Path
  17. IsGitHub = strings.HasPrefix(ModPath, "github.com/")
  18. }