MCPcopy
hub / github.com/keploy/keploy / isGoBinary

Function isGoBinary

utils/utils.go:1199–1219  ·  view source on GitHub ↗
(logger *zap.Logger, filePath string)

Source from the content-addressed store, hash-verified

1197}
1198
1199func isGoBinary(logger *zap.Logger, filePath string) bool {
1200 f, err := elf.Open(filePath)
1201 if err != nil {
1202 logger.Debug(fmt.Sprintf("failed to open file %s", filePath), zap.Error(err))
1203 return false
1204 }
1205 defer func() {
1206 if err := f.Close(); err != nil {
1207 LogError(logger, err, "failed to close file", zap.String("file", filePath))
1208 }
1209 }()
1210
1211 // Check for section names typical to Go binaries
1212 sections := []string{".go.buildinfo", ".gopclntab"}
1213 for _, section := range sections {
1214 if sect := f.Section(section); sect != nil {
1215 return true
1216 }
1217 }
1218 return false
1219}
1220
1221// DetectLanguage detects the language of the test command and returns the executable
1222func DetectLanguage(logger *zap.Logger, cmd string) (models.Language, string) {

Callers 1

DetectLanguageFunction · 0.85

Calls 5

LogErrorFunction · 0.85
DebugMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected