]> Cypherpunks repositories - gostls13.git/commitdiff
testing: use strings.SplitSeq and bytes.SplitSeq
authorapocelipes <seve3r@outlook.com>
Wed, 5 Feb 2025 12:19:12 +0000 (12:19 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 5 Feb 2025 23:53:08 +0000 (15:53 -0800)
To simplify the code. This is a follow-up for the CL 646216.

Change-Id: Ib09d1074a783482fb293527e9f1abeb3c02137c3
GitHub-Last-Rev: 2e7a6ad40cc22ea855e4d703ff39db9cc2c8a58e
GitHub-Pull-Request: golang/go#71568
Reviewed-on: https://go-review.googlesource.com/c/go/+/646755
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Salah (Globlost) <globlost@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/testing/slogtest/example_test.go
src/testing/testing.go
src/testing/testing_test.go

index 0517a4b8574d8c3e457c8557689f91c4cb9a9b77..88fd2427b2e6d7ae551a9426aa1bab7b3b42be25 100644 (file)
@@ -23,7 +23,7 @@ func Example_parsing() {
 
        results := func() []map[string]any {
                var ms []map[string]any
-               for _, line := range bytes.Split(buf.Bytes(), []byte{'\n'}) {
+               for line := range bytes.SplitSeq(buf.Bytes(), []byte{'\n'}) {
                        if len(line) == 0 {
                                continue
                        }
index 2bfa4b6db079922292eb6093f5228709463f58ef..aefcb84fc8de2017da8bae565cfae18adf3d386a 100644 (file)
@@ -2501,7 +2501,7 @@ func (m *M) stopAlarm() {
 }
 
 func parseCpuList() {
-       for _, val := range strings.Split(*cpuListStr, ",") {
+       for val := range strings.SplitSeq(*cpuListStr, ",") {
                val = strings.TrimSpace(val)
                if val == "" {
                        continue
index 797728c7a89b0af2bf387815604cba9b260a150e..addf6cad91d66707e60b096caa3d58ff097419de 100644 (file)
@@ -894,7 +894,7 @@ func TestRunningTestsInCleanup(t *testing.T) {
 
 func parseRunningTests(out []byte) (runningTests []string, ok bool) {
        inRunningTests := false
-       for _, line := range strings.Split(string(out), "\n") {
+       for line := range strings.SplitSeq(string(out), "\n") {
                if inRunningTests {
                        // Package testing adds one tab, the panic printer adds another.
                        if trimmed, ok := strings.CutPrefix(line, "\t\t"); ok {