package kafka import ( "errors" "github.com/Shopify/sarama" ) func SASLVersion(kafkaVersion sarama.KafkaVersion, saslVersion *int) (int16, error) { if saslVersion == nil { if kafkaVersion.IsAtLeast(sarama.V1_0_0_0) { return sarama.SASLHandshakeV1, nil } return sarama.SASLHandshakeV0, nil } switch *saslVersion { case 0: return sarama.SASLHandshakeV0, nil case 1: return sarama.SASLHandshakeV1, nil default: return 0, errors.New("invalid SASL version") } }