Skip to content

Consider reporting avoidable type conversion for untyped constants (typed constants are already handled). #20

Open
@dmitshur

Description

Consider the following Go program:

package main

import "fmt"

func main() {
	const foo = "foo"

	f(string(foo) + "bar")
}

func f(s string) {
	fmt.Println(s)
}

I expected unconvert to report that string(foo) is an unnecessary conversion, but it didn't.

$ unconvert
$ echo $?
0

Is that intentional, or a missing feature?

Tested using Go 1.8beta2 and latest version of unconvert and its depenencies:

$ go version
go version go1.8beta2 darwin/amd64
$ gostatus -v .../unconvert
     github.com/mdempsky/unconvert/...
$ go list -f '{{join .Deps "\n"}}' github.com/mdempsky/unconvert | gostatus -stdin -v
     github.com/kisielk/gotool/...
     golang.org/x/text/...
   $ golang.org/x/tools/...
	$ Stash exists
$ binstale unconvert
unconvert
	up to date: github.com/mdempsky/unconvert

/cc @dominikh in case this is a better fit for one of your tools.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions