// New creates a new Resource with the given minimum and maximum values. // min should be less than max and the units should be compatible. // The initial balance value is set to min. A Context name can be provided, or "" // if no Context is required. func New(min us.Quantity, max us.Quantity, c string) *Resource { var ctx *context.Context if c != "" { ctx = context.Ctx(c) } else { ctx, _ = context.DefineContext("", min.Symbol(), us.DefaultFormat) } if us.AreCompatible(min, max) && us.Less(min, max) { return &Resource{ctx.Convert(min), ctx.Convert(max), min, ctx} } return nil }