github.com/zeebo/goof@v0.0.0-20230907150950-e9457bc94477/process_go17_other.go (about)

     1  //go:build !go1.8 && !darwin
     2  // +build !go1.8,!darwin
     3  
     4  package goof
     5  
     6  import (
     7  	"debug/dwarf"
     8  	"debug/elf"
     9  
    10  	"github.com/zeebo/errs"
    11  )
    12  
    13  func openProc() (*dwarf.Data, error) {
    14  	fh, err := elf.Open("/proc/self/exe")
    15  	if err != nil {
    16  		return nil, errs.Wrap(err)
    17  	}
    18  	defer fh.Close()
    19  
    20  	data, err := fh.DWARF()
    21  	return data, errs.Wrap(err)
    22  }