5.5. User.AppendFile: Efficiently append data to an existing file

Implement this method:

AppendFile(filename string, data []byte) (err error)

If the file does not exist, return an error.

If the file does exist, append the given content to the file.

You are not required to check the integrity of the existing file before appending the new content (integrity verification is allowed, but not required). If you detect an integrity violation or the append operation cannot proceed for any reason, return an error.

  • filename (string) – File name

  • data ([]byte) – Data to be appended to an existing file.

Return type



Do not forget that your design must satisfy all requirements, including:

  1. The implementation of AppendFile() must satisfy the efficiency requirement (see Efficiency).

  2. Users can have multiple active user sessions at once (see User Sessions).