如何确定value.FieldByName(name)是否找到了字段?

I'm trying to figure out how to stop the execution of my program when the field is not found in the example below.

If FieldByName(key) returns a zero Value how can I warn the user that the field was not found?

field := mutable.FieldByName(key)

// need to figure out if the field exists before calling .Type() on it
if field.X == Y {
  log.Fatalf("Unable to find [%s] in Config object", key)
}

switch field.Type().Name() {
}

As you've already mentioned, the documentation for the reflect package states:

FieldByName returns the struct field with the given name. It returns the zero Value if no field was found

This is not the same as a type's zero value. Under the documentation for Value, we can read:

The zero Value represents no value. Its IsValid method returns false, its Kind method returns Invalid, its String method returns "", and all other methods panic. Most functions and methods never return an invalid value. If one does, its documentation states the conditions explicitly.

So, while the Len solution might work, a more descriptive way to test it is:

if !field.IsValid() {
  log.Fatalf("Unable to find [%s] in Config object", key)
}