cast icon indicating copy to clipboard operation
cast copied to clipboard

Cannot cast alias variable to int32

Open rolniuq opened this issue 10 months ago • 0 comments

Hello everyone. I'm facing the issue is I cannot convert the alias type to int32. This is an example

package main

import (
	"testing"

	"github.com/spf13/cast"
	"github.com/stretchr/testify/require"
)

type a string

func Test_Case(t *testing.T) {
	var anum a = "1"
	c := cast.ToInt32(anum)
	require.Equal(t, int32(1), c)
}

Thank you for your help

rolniuq avatar Apr 02 '24 09:04 rolniuq