Skip to content

Commit 1a5fcb6

Browse files
authored
Merge pull request #1 from go-sharp/feature/fix-openfiles
Fix open files while removing temp directory
2 parents 2a6d9e7 + 2780288 commit 1a5fcb6

File tree

2 files changed

+120
-1
lines changed

2 files changed

+120
-1
lines changed

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,120 @@
11
# go-offline-packager
22
A simple tool to manage dependencies in an air-gapped environment.
3+
4+
## Usage
5+
6+
```bash
7+
Usage:
8+
go-offline-packager.exe [OPTIONS] <command>
9+
10+
Application Options:
11+
--go-bin= Set full path to go binary (default: C:\Program
12+
Files\Go\bin\go.exe) [%GOP_GO_BIN%]
13+
-v, --verbose Verbose output
14+
15+
Help Options:
16+
-h, --help Show this help message
17+
18+
Available commands:
19+
pack Download modules and pack it into a zip file.
20+
publish-folder Publish archive to a folder so it can be used as proxy source.
21+
publish-jfrog Publish archive to jfrog artifactory (requires installed and configured jfrog-cli).
22+
version Show version.
23+
```
24+
25+
### Pack
26+
Pack will download all your dependencies and create a zip file with it.
27+
28+
```bash
29+
Usage:
30+
go-offline-packager.exe [OPTIONS] pack [pack-OPTIONS]
31+
32+
Download modules and pack it into a zip file.
33+
34+
Application Options:
35+
--go-bin= Set full path to go binary (default: C:\Program
36+
Files\Go\bin\go.exe) [%GOP_GO_BIN%]
37+
-v, --verbose Verbose output
38+
39+
Help Options:
40+
-h, --help Show this help message
41+
42+
[pack command options]
43+
-m, --module= Modules to pack (github.com/jessevdk/go-flags or
44+
github.com/jessevdk/go-flags@v1.4.0)
45+
-g, --go-mod-file= Pack all dependencies specified in go.mod file.
46+
-o, --out= Output file name of the zip archive. (default:
47+
gop_dependencies.zip)
48+
-t, --transitive Ensure all transitive dependencies are included.
49+
```
50+
One can either use `-m` to specify dependencies or use the `-g` flag to use an existing go.mod file.
51+
52+
#### Example
53+
```bash
54+
# Use the -m flag
55+
go-offline-packager.exe pack -t -v -m github.com/jessevdk/go-flags -m github.com/go-sharp/color@v1.9.1
56+
# Use a go.mod file
57+
go-offline-packager.exe pack -t -v -g go.mod
58+
```
59+
60+
### Publish Folder
61+
On the computer in the air gapped environment one can use `publish-folder` to extract the dependencies into a folder.
62+
```bash
63+
Usage:
64+
go-offline-packager.exe [OPTIONS] publish-folder [publish-folder-OPTIONS] ARCHIVE
65+
66+
Publish archive to a folder so it can be used as proxy source.
67+
68+
Application Options:
69+
--go-bin= Set full path to go binary (default: C:\Program
70+
Files\Go\bin\go.exe) [%GOP_GO_BIN%]
71+
-v, --verbose Verbose output
72+
73+
Help Options:
74+
-h, --help Show this help message
75+
76+
[publish-folder command options]
77+
-o, --out= Output folder for the archive.
78+
79+
[publish-folder command arguments]
80+
ARCHIVE: Path to archive with dependencies.
81+
```
82+
83+
#### Example
84+
```bash
85+
go-offline-packager.exe publish-folder -o mymodules gop_dependencies.zip
86+
Publish-Folder: extracting archive
87+
Publish-Folder: processing files
88+
Publish-Folder: published archive to: /home/snmed/mymodules
89+
Publish-Folder: hint: set GOPROXY to use folder for dependencies:
90+
go env -w GOPROXY=file:////home/snmed/mymodules
91+
Publish-Folder: hint: in an air-gapped env set GOSUMDB to of:
92+
go env -w GOSUMDB=off
93+
```
94+
95+
### Publish JFrog Artifactory
96+
On the computer in the air gapped environment one can use `publish-jfrog` to upload dependencies into a JFrog Artifactory.
97+
> Caveat: jfrog-cli must be installed and configured, otherwise dependencies can't be uploaded. Binary will be found automatically if installed in a OS search path, otherwise one has to specify the path to the binary.
98+
99+
```bash
100+
Usage:
101+
go-offline-packager.exe [OPTIONS] publish-jfrog [publish-jfrog-OPTIONS] ARCHIVE
102+
103+
Publish archive to jfrog artifactory (requires installed and configured
104+
jfrog-cli).
105+
106+
Application Options:
107+
--go-bin= Set full path to go binary (default: C:\Program
108+
Files\Go\bin\go.exe) [%GOP_GO_BIN%]
109+
-v, --verbose Verbose output
110+
111+
Help Options:
112+
-h, --help Show this help message
113+
114+
[publish-jfrog command options]
115+
--jfrog-bin= Set full path to the jfrog-cli binary [%GOP_JFROG_BIN%]
116+
-r, --repo= Artifactory go repository name ex. go-local.
117+
118+
[publish-jfrog command arguments]
119+
ARCHIVE: Path to archive with dependencies.
120+
```

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/jessevdk/go-flags"
1717
)
1818

19-
const version = "v0.1.0"
19+
const version = "v0.1.1"
2020

2121
var commonOpts options
2222
var parser = flags.NewParser(&commonOpts, flags.HelpFlag|flags.PassDoubleDash)
@@ -209,6 +209,7 @@ func createZipArchive(dir, dst string) error {
209209
log.Printf("%v failed to add to archive: %v\n", errorRedPrefix, err)
210210
continue
211211
}
212+
defer reader.Close()
212213

213214
fiStat, err := os.Stat(f)
214215
if err != nil {

0 commit comments

Comments
 (0)