cmd/go/internal/modload: in newRequirements, verify that rootModules is sorted
cmd/go/internal/modload: in newRequirements, verify that rootModules is sorted

The comment for the Requirements.rootModules field requires that it be
"sorted and capped to length". I noticed that we were not capping it
correctly — we were capping the local variable (the rorotModules
argument itself) but not the struct field. That prompted me to
question whether we were also at some point failing to sort it
correctly, so I decided to add an explicit check.

With the explicit check, all tests continue to pass.

For #36460

Change-Id: I6687de8ef8ecc5129fa8810d678e5673752fd27b
Reviewed-on: https://go-review.googlesource.com/c/go/+/310790
Trust: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
Run-TryBot: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
TryBot-Result: Go Bot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Jay Conrod <f3fadaedc813344da5ec13b41e26596889cc5baa@google.com>
Reviewed-by: Michael Matloob <4562438b12c14e81a47550acde616ff328a909f8@golang.org>

CAFxX/go,cloudflare/go,nawawi/go,nawawi/go,CAFxX/go,golang/go,CAFxX/go,golang/go,cloudflare/go,CAFxX/go,CAFxX/go,cloudflare/go,cloudflare/go,nawawi/go,golang/go,golang/go,nawawi/go,cloudflare/go,golang/go,nawawi/go,CAFxX/go,golang/go,cloudflare/go,nawawi/go,CAFxX/go,cloudflare/go,cloudflare/go,golang/go,nawawi/go,golang/go,CAFxX/go,nawawi/go