MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / compressExeAndArgs

Function compressExeAndArgs

cmd/build-lambda-zip/main.go:71–110  ·  view source on GitHub ↗
(outZipPath string, exePath string, args []string)

Source from the content-addressed store, hash-verified

69}
70
71func compressExeAndArgs(outZipPath string, exePath string, args []string) error {
72 zipFile, err := os.Create(outZipPath)
73 if err != nil {
74 return err
75 }
76 defer func() {
77 closeErr := zipFile.Close()
78 if closeErr != nil {
79 fmt.Fprintf(os.Stderr, "Failed to close zip file: %v\n", closeErr)
80 }
81 }()
82
83 zipWriter := zip.NewWriter(zipFile)
84 defer zipWriter.Close()
85 data, err := ioutil.ReadFile(exePath)
86 if err != nil {
87 return err
88 }
89
90 err = writeExe(zipWriter, filepath.Base(exePath), data)
91 if err != nil {
92 return err
93 }
94
95 for _, arg := range args {
96 writer, err := zipWriter.Create(arg)
97 if err != nil {
98 return err
99 }
100 data, err := ioutil.ReadFile(arg)
101 if err != nil {
102 return err
103 }
104 _, err = writer.Write(data)
105 if err != nil {
106 return err
107 }
108 }
109 return err
110}

Callers 3

TestSizesFunction · 0.85
TestCompressExeAndArgsFunction · 0.85
mainFunction · 0.85

Calls 3

writeExeFunction · 0.85
WriteMethod · 0.80
CloseMethod · 0.45

Tested by 2

TestSizesFunction · 0.68
TestCompressExeAndArgsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…