micro_topic.go 376 B

12345678910111213141516171819202122
  1. package topic
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. const (
  7. TOPPrefix = "go-top"
  8. )
  9. func TOP(path string) string {
  10. return joinPath(TOPPrefix, path)
  11. }
  12. func joinPath(prefix string, path string) string {
  13. if strings.TrimSpace(path) == "" {
  14. return prefix
  15. }
  16. path = strings.TrimLeft(strings.TrimLeft(strings.TrimSpace(path), "/"), "\\")
  17. return fmt.Sprintf("%s.%s", prefix, path)
  18. }