Documentation ΒΆ
Overview ΒΆ
Package typeconv provides missing implicit type conversion in Go by rewriting AST.
Index ΒΆ
Constants ΒΆ
View Source
const ( // cannot use x (variable of type int) as uint value in variable declaration TypeErrVarDecl typErr = iota // cannot use x (variable of type int) as float64 value in argument to funcarg TypeErrFuncArg // cannot use y (variable of type int) as float64 value in assignment TypeErrAssign // invalid operation: mismatched types int and float64 TypeErrMismatched // cannot use x (variable of type int) as float64 value in return statement TypeErrReturn )
Variables ΒΆ
View Source
var DefaultRule = &Rule{}
DefaultRule holds default type conversion rules whose conversion are safe.
Functions ΒΆ
Types ΒΆ
type ErrFuncArg ΒΆ
type ErrFuncArg struct { ParamType string // https://golang.org/pkg/go/ast/#FuncType ArgType string // https://golang.org/pkg/go/ast/#CallExpr }
ErrFuncArg represents type error at function arguments.
type ErrMismatched ΒΆ
ErrMismatched represents mismatched type error.
type ErrVarDecl ΒΆ
ErrVarDecl represents type error of variable declaration.
Example:
var x, y int = 3, 4 var _ float64 = x*x + y*y var _ uint = x var _ uint = int(1) var _ uint = int(1) + int(1)
Error:
cannot use x * x + y * y (value of type int) as float64 value in variable declaration cannot use x (variable of type int) as uint value in variable declaration cannot use int(1) (constant 1 of type int) as uint value in variable declaration cannot use int(1) + int(1) (constant 2 of type int) as uint value in variable declaration
Click to show internal directories.
Click to hide internal directories.