code: func runInDir(program []byte, dir string) (*model.Package, error) {
  	// We use TempDir instead of TempFile so we can control the filename.
  	tmpDir, err := ioutil.TempDir(dir, "gomock_reflect_")
  	if err != nil {
  		return nil, err
  	}
  	defer func() {
  		if err := os.RemoveAll(tmpDir); err != nil {
  			log.Printf("failed to remove temp directory: %s", err)
  		}
  	}()
  	const progSource = "prog.go"
  	var progBinary = "prog.bin"
  	if runtime.GOOS == "windows" {
  		// Windows won't execute a program unless it has a ".exe" suffix.
  		progBinary += ".exe"
  	}
  
  	if err := ioutil.WriteFile(filepath.Join(tmpDir, progSource), program, 0600); err != nil {
  		return nil, err
  	}
  
  	cmdArgs := []string{}
  	cmdArgs = append(cmdArgs, "build")
  	if *buildFlags != "" {
  		cmdArgs = append(cmdArgs, *buildFlags)
  	}
  	cmdArgs = append(cmdArgs, "-o", progBinary, progSource)
  
  	// Build the program.
  	cmd := exec.Command("go", cmdArgs...)
  	cmd.Dir = tmpDir
  	cmd.Stdout = os.Stdout
  	cmd.Stderr = os.Stderr
  	if err := cmd.Run(); err != nil {
  		return nil, err
  	}
  	return run(filepath.Join(tmpDir, progBinary))
  }
docs: // runInDir writes the given program into the given dir, runs it there, and
  // parses the output as a model.Package.