| 1197 | } |
| 1198 | |
| 1199 | func 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 |
| 1222 | func DetectLanguage(logger *zap.Logger, cmd string) (models.Language, string) { |