tail_service_test.go 678 B

12345678910111213141516171819202122232425262728293031323334
  1. package services
  2. import (
  3. "fmt"
  4. "strings"
  5. "testing"
  6. )
  7. func Test(t *testing.T) {
  8. str := "hello world this is a test"
  9. x, y, z := splitString(str)
  10. fmt.Println(x)
  11. fmt.Println(y)
  12. fmt.Println(z)
  13. }
  14. func splitString(str string) (beforeFirstSpace, afterLastSpace, middle string) {
  15. firstSpaceIndex := strings.Index(str, " ")
  16. if firstSpaceIndex != -1 {
  17. beforeFirstSpace = str[:firstSpaceIndex]
  18. lastSpaceIndex := strings.LastIndex(str, " ")
  19. if lastSpaceIndex != -1 {
  20. afterLastSpace = str[lastSpaceIndex+1:]
  21. middle = str[firstSpaceIndex+1 : lastSpaceIndex]
  22. }
  23. }
  24. return
  25. }
  26. func TestNewDate(t *testing.T) {
  27. str := "07/Jan/2025:12:42:46 +0800"
  28. fmt.Println(str)
  29. }