I am seeing very inconsistent highlighting of constants and variables depending on context. I updated the language-go package from version 0.39.0 to 0.41.0 and Atom from version 1.2.4 to 1.3.2, just to ensure that I was up-to-date but I still get the same inconsistencies.
I am using the One Dark theme for both UI and Syntax Themes. Linux Mint 17.1 KDE desktop. I have tested for these errors, with essentially the same results, using various themes.
Here is a summary of what I am seeing:
- When I declare a const the name is red.
const fourtyTwo = 42 // "fourtyTwo" is red
(that's usual)
- In something like
meaning := fourtyTwo
fourtyTwo is now gray.
- When I define a struct the field names are gray.
type user struct{ name string } // "name" is gray
(seems like they should also be red)
- When I make a custom type and I use a built-in type, the built-in type's name is highlighted purple.
type color uint8 // "uint8" is purple
(the usual color)
- When I make a custom type from a user defined type it is gray.
type hue color //"color" is gray
(maybe that's intentional... not a reserved word, so purple doesn't make sense and gold would look odd... I don't have a great suggestion here.)
- When I use the var key word the name of the variable is red.
var name string //"name" is red
(usual)
- When I do something with the same variable later it is gray.
len(name) // now "name" is gray
(shouldn't it be red?)
- When I assign using := the left side var name is red; the right side gray. So in
bar := foo // "bar" red, "foo" gray
Really real examples:
const (
dbUser = "user"
dbPassword = "password"
dbName = "maintenance"
dbHost = "database.host"
)
In this context "dbUser", "dbPassword", "dbName" and "dbHost" are all highlighted red.
Later in the code:
dbinfo := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=require",
dbUser,
dbPassword,
dbName,
dbHost,
)
In this context "dbUser", "dbPassword", "dbName" and "dbHost" are each gray.
The example var db *sql.DB
and db, err = sql.Open("postgres", dbinfo)
highlights the variables "db" and "err" in red, then later defer db.Close()
has "db" in gray and "err" when checked, as in if err != nil {...}
is gray.
In item := r.PostFormValue("item")
"item" (left side) is red and "r" is gray. A few lines later "item", when used in the args for db.Query()
, is gray.
Also in item := r.PostFormValue("item")
"PostFormValue" is blue but in if r.Method == "POST" {...}
"Method" is in gray.
And another: var i int
"i" is a red and a couple of lines later in i++
the "i" is gray.
A couple of other odd ones:
"string" as a type highlights green var name string // "string" is green
(the same color as string literals). All other built-in types seem to highlight purple.
Package names used to highlight, as in "http" from http.ListenAndServe
and now are gray.
func/method parameters used to be red (as were the arguments passed in if I recall correctly) , now they are gray. They are at least consistent to each other, but they felt more comfortable to me when they matched the red pattern of variables.