您可以声明一个集成了constraints.Floatand的新类型约束constraints.Integer。// Number is a custom type set of constraints extending the Float and Integer type set from the experimental constraints package.type Number interface { constraints.Float | constraints.Integer}