Skip to content

Cannot cast alias variable to int32 #215

@rolniuq

Description

@rolniuq

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

Metadata

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