github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/module/pcdata_patcher1.15.go (about) 1 //go:build go1.15 && !go1.16 2 // +build go1.15,!go1.16 3 4 package module 5 6 7 8 func (p *PCDataPatcher) CreatePCFile(oldTable []PCDataEntry) ([]PCDataEntry, map[int32]int32, error) { 9 oldFilenosToNew := make(map[int32]int32) 10 i := int32(0) 11 for _, entry := range oldTable { 12 if _, ok := oldFilenosToNew[entry.Value]; !ok { 13 oldFilenosToNew[entry.Value] = i 14 i++ 15 } 16 } 17 18 newTable, err := p.createSanitized(oldTable, 19 func(table []PCDataEntry) ([]PCDataEntry, error) { 20 err := p.updateOffsets(table) 21 if err != nil { 22 return nil, err 23 } 24 25 26 for i := range table { 27 table[i].Value = oldFilenosToNew[table[i].Value] 28 } 29 return table, nil 30 }) 31 if err != nil { 32 return nil, nil, err 33 } 34 35 return newTable, oldFilenosToNew, nil 36 }