{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/28620","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/28620/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/28620/comments","events_url":"https://api.github.com/repos/golang/go/issues/28620/events","html_url":"https://github.com/golang/go/issues/28620","id":377976033,"node_id":"MDU6SXNzdWUzNzc5NzYwMzM=","number":28620,"title":"strings.Split on space weird behavior, but only with a slice","user":{"login":"jpttsn","id":1417756,"node_id":"MDQ6VXNlcjE0MTc3NTY=","avatar_url":"https://avatars2.githubusercontent.com/u/1417756?v=4","gravatar_id":"","url":"https://api.github.com/users/jpttsn","html_url":"https://github.com/jpttsn","followers_url":"https://api.github.com/users/jpttsn/followers","following_url":"https://api.github.com/users/jpttsn/following{/other_user}","gists_url":"https://api.github.com/users/jpttsn/gists{/gist_id}","starred_url":"https://api.github.com/users/jpttsn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpttsn/subscriptions","organizations_url":"https://api.github.com/users/jpttsn/orgs","repos_url":"https://api.github.com/users/jpttsn/repos","events_url":"https://api.github.com/users/jpttsn/events{/privacy}","received_events_url":"https://api.github.com/users/jpttsn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-06T18:25:26Z","updated_at":"2018-11-06T18:34:18Z","closed_at":null,"author_association":"NONE","body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n#### What did you do?\r\n\r\nDebugged this as far as I could, and got a minimal failing test.\r\n\r\n```golang\r\n    //When passing in a string literal, split manages.\r\n\ty := strings.Split(\"xx xx\", \" \")\r\n\tt.Logf(\"len(%v) = %v\", y, len(y))\r\n\tif len(y) != 2 {\r\n\t\tt.Fatal(\"split failed and we got back one value\", x[0])\r\n\t}\r\n\r\n  //But if I pass in the same exact string via a slice, it doesn't\r\n  //This took a while to figure out because it was originally in a for-range over the groups slice\r\n\tgroups := []string{\r\n\t\t\"xx xx\",\r\n\t}\r\n\tgroup := groups[0]\r\n\tx := strings.Split(group, \" \")\r\n\tt.Logf(\"len(%v) = %v\", x, len(x))\r\n\tif len(x) != 2 {\r\n\t\tt.Fatal(\"split failed and we got back one value\", x[0])\r\n\t}\r\n```\r\n\r\n\r\n#### What did you expect to see?\r\n\r\nI expect strings.Split to split my string, or maybe fail to split it (if the separator can't be found).\r\n\r\n#### What did you see instead?\r\n\r\nSplit works if I pass in a string literal, but fails if I pass the same string from a slice.\r\n\r\nI might be missing something. Seems to me Split should split or fail to split depending on the contents of the string, regardless if it comes form a literal or from a slice.\r\n\r\nTested some other separators, and it works consistently with comma etc. But with a single space as `sep` the inconsistency appears.\r\n\r\n#### Does this issue reproduce with the latest release (go1.11.2)?\r\n\r\nYup. Upgraded after I generated this bug report and confirmed it.\r\n\r\n#### System details\r\n\r\nRecent Macbook, Go installed via homebrew.\r\n\r\n```\r\ngo version go1.11.1 darwin/amd64\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/Users/joel/Library/Caches/go-build\"\r\nGOEXE=\"\"\r\nGOFLAGS=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"darwin\"\r\nGOOS=\"darwin\"\r\nGOPATH=\"/Users/joel/Developer/go\"\r\nGOPROXY=\"\"\r\nGORACE=\"\"\r\nGOROOT=\"/usr/local/Cellar/go/1.11.1/libexec\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/usr/local/Cellar/go/1.11.1/libexec/pkg/tool/darwin_amd64\"\r\nGCCGO=\"gccgo\"\r\nCC=\"clang\"\r\nCXX=\"clang++\"\r\nCGO_ENABLED=\"1\"\r\nGOMOD=\"/Users/joel/Developer/dinnerbot/go.mod\"\r\nGOROOT/bin/go version: go version go1.11.1 darwin/amd64\r\nGOROOT/bin/go tool compile -V: compile version go1.11.1\r\nuname -v: Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64\r\nProductName:\tMac OS X\r\nProductVersion:\t10.14.1\r\nBuildVersion:\t18B75\r\nlldb --version: lldb-1000.11.38.2\r\n  Swift-4.2\r\n```"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/436359807","html_url":"https://github.com/golang/go/issues/28620#issuecomment-436359807","issue_url":"https://api.github.com/repos/golang/go/issues/28620","id":436359807,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjM1OTgwNw==","user":{"login":"martisch","id":184995,"node_id":"MDQ6VXNlcjE4NDk5NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/184995?v=4","gravatar_id":"","url":"https://api.github.com/users/martisch","html_url":"https://github.com/martisch","followers_url":"https://api.github.com/users/martisch/followers","following_url":"https://api.github.com/users/martisch/following{/other_user}","gists_url":"https://api.github.com/users/martisch/gists{/gist_id}","starred_url":"https://api.github.com/users/martisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martisch/subscriptions","organizations_url":"https://api.github.com/users/martisch/orgs","repos_url":"https://api.github.com/users/martisch/repos","events_url":"https://api.github.com/users/martisch/events{/privacy}","received_events_url":"https://api.github.com/users/martisch/received_events","type":"User","site_admin":false},"created_at":"2018-11-06T18:34:18Z","updated_at":"2018-11-06T18:34:18Z","author_association":"MEMBER","body":"Then please post the complete minimal program that is run with go test and reproduces an issue."}}
{"actor":{"display_login":"martisch"}}