alg.go
func (alg *Algorithm) UnmarshalText(buf []byte) error {
	switch string(buf) {
	// hmac
	case "HS256":
		*alg = HS256
	case "HS384":
		*alg = HS384
	case "HS512":
		*alg = HS512

	// rsa-pkcs1v15
	case "RS256":
		*alg = RS256
	case "RS384":
		*alg = RS384
	case "RS512":
		*alg = RS512

	// ecc
	case "ES256":
		*alg = ES256
	case "ES384":
		*alg = ES384
	case "ES512":
		*alg = ES512

	// rsa-pss
	case "PS256":
		*alg = PS256
	case "PS384":
		*alg = PS384
	case "PS512":
		*alg = PS512

	// error
	default:
		return ErrInvalidAlgorithm
	}

	return nil
}
func (alg *Algorithm) UnmarshalText(buf []byte) error {
	switch string(buf) {
	// hmac
	case "HS256":
		*alg = HS256
	case "HS384":
		*alg = HS384
	case "HS512":
		*alg = HS512

	// rsa-pkcs1v15
	case "RS256":
		*alg = RS256
	case "RS384":
		*alg = RS384
	case "RS512":
		*alg = RS512

	// ecc
	case "ES256":
		*alg = ES256
	case "ES384":
		*alg = ES384
	case "ES512":
		*alg = ES512

	// rsa-pss
	case "PS256":
		*alg = PS256
	case "PS384":
		*alg = PS384
	case "PS512":
		*alg = PS512

	// error
	default:
		return ErrInvalidAlgorithm
	}

	return nil
}
func ( alg * Algorithm ) UnmarshalText ( buf [ ] byte ) error { switch string ( buf ) { // hmac case " " : * alg = HS256 case " " : * alg = HS384 case " " : * alg = HS512 // rsa-pkcs1v15 case " " : * alg = RS256 case " " : * alg = RS384 case " " : * alg = RS512 // ecc case " " : * alg = ES256 case " " : * alg = ES384 case " " : * alg = ES512 // rsa-pss case " " : * alg = PS256 case " " : * alg = PS384 case " " : * alg = PS512 // error default : return ErrInvalidAlgorithm } return nil }
// UnmarshalText attempts to unmarshal buf into an Algorithm.
UnmarshalText attempts to unmarshal buf into an Algorithm .