了解GO变量分配

I'm new to GO and trying to build functions with the aws-sdk I have something like this

    input := &rds.CreateDBClusterSnapshotInput{
        // removed for brevity
    }

    result, err := svc.CreateDBClusterSnapshot(input)
    if err != nil {
        // removed for brevity
    }

    input = &rds.ModifyDBClusterSnapshotAttributeInput{
        // removed for brevity
    }

When I try to build, I get this error

cannot use &rds.ModifyDBClusterSnapshotAttributeInput literal (type *rds.ModifyDBClusterSnapshotAttributeInput) as type *rds.CreateDBClusterSnapshotInput in assignment

What's wrong with my assignment?

As @Sergio Tulentsev pointed out, you are assigning ModifyDBClusterSnapshotAttributeInput type to the variable input, that is a CreateDBClusterSnapshotInput type.

There would be a few solutions to handle this problem, but the easiest way would be to make a method for each type struct that returns a compatible type for input like this;

func (createInput CreateDBClusterSnapshotInput) ReturnInput() {
    return createInput.input // assuming that there are a input type your create
}

If you don't want to make a method with the same functionality for each struct, you can create a base type, make your two structs extend the type, and build a method for the base type.