code: func ValidateArchive(tr *tar.Reader) error {
  	var fseen map[string]bool = make(map[string]bool)
  	var imOK, rfsOK bool
  	var im bytes.Buffer
  Tar:
  	for {
  		hdr, err := tr.Next()
  		switch {
  		case err == nil:
  		case err == io.EOF:
  			break Tar
  		default:
  			return err
  		}
  		name := filepath.Clean(hdr.Name)
  		switch name {
  		case ".":
  		case ManifestFile:
  			_, err := io.Copy(&im, tr)
  			if err != nil {
  				return err
  			}
  			imOK = true
  		case RootfsDir:
  			if !hdr.FileInfo().IsDir() {
  				return fmt.Errorf("rootfs is not a directory")
  			}
  			rfsOK = true
  		default:
  			if _, seen := fseen[name]; seen {
  				return fmt.Errorf("duplicate file entry in archive: %s", name)
  			}
  			fseen[name] = true
  		}
  	}
  	var flist []string
  	for key := range fseen {
  		flist = append(flist, key)
  	}
  	return validate(imOK, &im, rfsOK, flist)
  }
docs: // ValidateArchive takes a *tar.Reader and validates that the layout of the
  // filesystem the reader encapsulates matches that expected by the
  // Application Container Image format.  If any errors are encountered during
  // the validation, it will abort and return the first one.