code: func (r *renderedStack) dumpTo(w io.Writer, excludePkgs ...string) (n int, err error) {
  	excludeSet := stringset.NewFromSlice(excludePkgs...)
  
  	return iotools.WriteTracker(w, func(w io.Writer) error {
  		fmt.Fprintf(w, "goroutine %d:\n", r.goID)
  
  		lastIdx := 0
  		needNL := false
  		skipCount := 0
  		skipPkg := ""
  		flushSkips := func(extra string) {
  			if skipCount != 0 {
  				if needNL {
  					w.Write(nlSlice)
  					needNL = false
  				}
  				fmt.Fprintf(w, "... skipped %d frames in pkg %q...\n%s", skipCount, skipPkg, extra)
  				skipCount = 0
  				skipPkg = ""
  			}
  		}
  		for i, f := range r.frames {
  			if needNL {
  				w.Write(nlSlice)
  				needNL = false
  			}
  			if excludeSet.Has(f.pkg) {
  				if skipPkg == f.pkg {
  					skipCount++
  				} else {
  					flushSkips("")
  					skipCount++
  					skipPkg = f.pkg
  				}
  				continue
  			}
  			flushSkips("\n")
  			if len(f.wrappers) > 0 {
  				f.dumpWrappersTo(w, lastIdx, i)
  				w.Write(nlSlice)
  			}
  			if len(f.annotations) > 0 {
  				lastIdx = i
  				needNL = true
  			}
  			f.dumpTo(w, i)
  		}
  		flushSkips("")
  
  		return nil
  	})
  }
docs: // dumpTo formats the full stack.