github.com/go-playground/pkg/v5@v5.29.1/net/http/quality_value.go (about) 1 package httpext 2 3 import "fmt" 4 5 const ( 6 // QualityValueFormat is a format string helper for Quality Values 7 QualityValueFormat = "%s;q=%1.3g" 8 ) 9 10 // QualityValue accepts a values to add/concatenate a quality values to and 11 // the quality values itself. 12 func QualityValue(v string, qv float32) string { 13 if qv > 1 { 14 qv = 1 // highest possible values 15 } 16 if qv < 0.001 { 17 qv = 0.001 // lowest possible values 18 } 19 return fmt.Sprintf(QualityValueFormat, v, qv) 20 }