commit | 2a5cf48f91c0a59eeb01b97ca6afaca311324206 | [log] [tgz] |
---|---|---|
author | Robert Griesemer <gri@golang.org> | Wed Mar 08 14:26:23 2017 -0800 |
committer | Robert Griesemer <gri@golang.org> | Thu Mar 09 23:29:49 2017 +0000 |
tree | 5339eccd133a85766d510fb5188c2ba0c4f6e96a | |
parent | 1f9f0ea32b2dcee027b107f2c3d0bc723274a810 [diff] |
cmd/compile: print columns (not just lines) in error messages Compiler errors now show the exact line and line byte offset (sometimes called "column") of where an error occured. For `go tool compile x.go`: package p const c int = false //line foo.go:123 type t intg reports x.go:2:7: cannot convert false to type int foo.go:123[x.go:4:8]: undefined: intg (Some errors use the "wrong" position for the error message; arguably the byte offset for the first error should be 15, the position of 'false', rathen than 7, the position of 'c'. But that is an indepedent issue.) The byte offset (column) values are measured in bytes; they start at 1, matching the convention used by editors and IDEs. Positions modified by //line directives show the line offset only for the actual source location (in square brackets), not for the "virtual" file and line number because that code is likely generated and the //line directive only provides line information. Because the new format might break existing tools or scripts, printing of line offsets can be disabled with the new compiler flag -C. We plan to remove this flag eventually. Fixes #10324. Change-Id: I493f5ee6e78457cf7b00025aba6b6e28e50bb740 Reviewed-on: https://go-review.googlesource.com/37970 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project does not use GitHub pull requests, and that we use the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.