Skip to content

Commit

Permalink
add FilesWithNames()
Browse files Browse the repository at this point in the history
  • Loading branch information
MayCXC authored Oct 9, 2024
1 parent 7d375ec commit 3b1abc8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions activation/files_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,22 @@ func Files(unsetEnv bool) []*os.File {

return files
}

// FilesWithNames maps fd names to a set of os.File pointers.
func FilesWithNames() map[string][]*os.File {
files := activation.Files(true)

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build on minimum supported toolchain

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Distro test (debian:bullseye)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build (1.17.x)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Distro test (ubuntu:20.04)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build (1.18.x)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Distro test (ubuntu:22.04)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build (1.19.x)

undefined: activation

Check failure on line 74 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build (1.20.x)

undefined: activation
filesWithNames := map[string][]*os.File{}

for _, f := range files {
current, ok := filesWithNames[f.Name()]

Check failure on line 78 in activation/files_unix.go

View workflow job for this annotation

GitHub Actions / Build (1.17.x)

assignment mismatch: 2 variables but 1 value

if !ok {
current = []*os.File{}
filesWithNames[f.Name()] = current
}

filesWithNames[f.Name()] = append(current, f)
}

return filesWithNames
}

0 comments on commit 3b1abc8

Please sign in to comment.