Skip to content

cmd/compile: non-deterministic output order for unused import errors #20298

Closed

Description

@josharian

Compile this file multiple times:

package p

import (
        "bufio"
        "bytes"
        "crypto/x509"
        "flag"
        "fmt"
        "io"
        "io/ioutil"
        "log"
        "math"
        "math/big"
        "math/bits"
        "net"
        "net/http"
        "os"
        "path"
        "path/filepath"
        "regexp"
        "strings"
)

The output varies. Two sample runs:

$ go tool compile x.go 
x.go:6:2: imported and not used: "crypto/x509"
x.go:9:2: imported and not used: "io"
x.go:10:2: imported and not used: "io/ioutil"
x.go:11:2: imported and not used: "log"
x.go:12:2: imported and not used: "math"
x.go:13:2: imported and not used: "math/big"
x.go:16:2: imported and not used: "net/http"
x.go:18:2: imported and not used: "path"
x.go:19:2: imported and not used: "path/filepath"
x.go:21:2: imported and not used: "strings"
x.go:10:2: too many errors
$ go tool compile x.go 
x.go:4:2: imported and not used: "bufio"
x.go:5:2: imported and not used: "bytes"
x.go:11:2: imported and not used: "log"
x.go:12:2: imported and not used: "math"
x.go:13:2: imported and not used: "math/big"
x.go:14:2: imported and not used: "math/bits"
x.go:15:2: imported and not used: "net"
x.go:17:2: imported and not used: "os"
x.go:20:2: imported and not used: "regexp"
x.go:21:2: imported and not used: "strings"
x.go:14:2: too many errors

It'd be preferable for the output to be deterministic.

Fix is easy and safe; CL soon.

Activity

  1. added this to the Go1.9 milestone on May 9, 2017
  2. gopherbot commented on May 9, 2017

    @gopherbot
    Contributor

    CL https://golang.org/cl/42954 mentions this issue.

  3. locked and limited conversation to collaborators on May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions