Skip to content

confuse with "go vet error is not a type" #33668

Closed
@wangcheng711

Description

@wangcheng711

What version of Go are you using (go version)?

$ go version
go version go1.12.7 linux/amd64

What did you do?

the sample code:

package main

import (
	"log"
	"os"
)

func main() {
	file, error := os.Open("hs.json")
	if error != nil {
		log.Println("open file ", error)
		return
	}
	defer file.Close()
	h := func(string) error {
		return nil
	}
	h("hello")

}

What did you see instead?

i am beginner with golang, the go vet output is 'error is not a type'. so, it can be confusing to fix problem

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions