12345678910111213141516171819202122232425262728293031323334 |
- package services
- import (
- "fmt"
- "strings"
- "testing"
- )
- func Test(t *testing.T) {
- str := "hello world this is a test"
- x, y, z := splitString(str)
- fmt.Println(x)
- fmt.Println(y)
- fmt.Println(z)
- }
- func splitString(str string) (beforeFirstSpace, afterLastSpace, middle string) {
- firstSpaceIndex := strings.Index(str, " ")
- if firstSpaceIndex != -1 {
- beforeFirstSpace = str[:firstSpaceIndex]
- lastSpaceIndex := strings.LastIndex(str, " ")
- if lastSpaceIndex != -1 {
- afterLastSpace = str[lastSpaceIndex+1:]
- middle = str[firstSpaceIndex+1 : lastSpaceIndex]
- }
- }
- return
- }
- func TestNewDate(t *testing.T) {
- str := "07/Jan/2025:12:42:46 +0800"
- fmt.Println(str)
- }
|