packagedbusimport("encoding/hex")// AuthExternal returns an Auth that authenticates as the given user with the// EXTERNAL mechanism.funcAuthExternal(userstring)Auth{returnauthExternal{user}}// AuthExternal implements the EXTERNAL authentication mechanism.typeauthExternalstruct{userstring}func(aauthExternal)FirstData()([]byte,[]byte,AuthStatus){b:=make([]byte,2*len(a.user))hex.Encode(b,[]byte(a.user))return[]byte("EXTERNAL"),b,AuthOk}func(aauthExternal)HandleData(b[]byte)([]byte,AuthStatus){returnnil,AuthError}