如果os / exec包中的Go类型ExitError不在文档中,则如何支持Sys()方法?

Based on various examples on the web and in the answer to this SO question, I am trying to figure out how it is possible for type ExitError from package os/exec to support the Sys() method even if the docs only mention the Error() method for this type.

I've guessed that the Sys() method in question is from type ProcessState in package os, but how does ExitError get to use it directly (exiterror.Sys()) without having to use the full (exiterror.ProcessState.Sys())?

This must be a basic Go question but I've yet to figure out the answer to this one one my own...

cmd.Wait() already returns error of type *ExitError. If you look at ExitError's definition, you can see that it embeds *os.ProcessState:

type ExitError struct {
        *os.ProcessState
        // other fields
}

It is through *os.ProcessState that a value of type ExitError can call Sys() method.

Note that within the definition of ExitError, there is no field name associated with *os.ProcessState, which means that a value of type ExitError can directly call any method on *os.ProcessState (sort of like inheritance, where ExitError inherits *os.ProcessState. But this is only to give you a very basic idea. Read the docs for clarification.) as long as there is no method defined on ExitError with the same name.

There is of course more to it. You can read about it here.