You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: global.go
    path of file: ./repos/easeprobe/global
    
    the code of the file until where you have to start completion: /*
 * Copyright (c) 2022, MegaEase
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "
    
func EnumUnmarshalJSON[T comparable](b []byte, m map[string]T, v *T, init T, typename string) error {
	var str string
	*v = init
	if err := json.Unmarshal(b, &str); err != nil {
		return err
	}
	if val, ok := m[strings.ToLower(str)]; ok {
		*v = val
		return nil
	}
	return fmt.Errorf("%v is not a valid %s", str, typename)
}