Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use this? #2

Open
fgl87 opened this issue Jul 17, 2015 · 2 comments
Open

How do I use this? #2

fgl87 opened this issue Jul 17, 2015 · 2 comments

Comments

@fgl87
Copy link

fgl87 commented Jul 17, 2015

I installed go, I used GET to download the files from GIT, but when I use BUILD I can't turn the package in something executable. How do I use this?

@Hibbem
Copy link

Hibbem commented Jan 11, 2025

Hi! I also had some trouble using this, as I am not familiar w/ Go.
Here are the steps to proceed:

  • download Go binaries from the website: https://go.dev/dl/
  • make sure go is installed correctly by executing go version. Make sure to open a new terminal, so the updated path can be loaded :)
  • create a new folder and place this compress.go script inside:
package main

import (
	"fmt"
	"log"
	"github.com/yani-/wpress"
)


func main() {
	// Define the output .wpress file
	archiveFilename := "output.wpress"

	// Create a new Writer instance
	writer, err := wpress.NewWriter(archiveFilename)
	if err != nil {
		log.Fatalf("Failed to create archive: %v", err)
	}

	folderToCompress := "/path/to/directory/to/add"

	// Add folder to the archive
	err = writer.AddDirectory(folderToCompress)
	if err != nil {
		log.Fatalf("Failed to add file to archive: %v", err)
	}

	// Close the writer to finalize the archive
	err = writer.Close()
	if err != nil {
		log.Fatalf("Failed to close archive: %v", err)
	}

	fmt.Printf("Folder %s successfully compressed into %s\n", folderToCompress, archiveFilename)
}
  • execute go mod init my-compressor and go mod tidy
  • finally execute the script via go run compress.go

Hope this helps!

@Hibbem
Copy link

Hibbem commented Jan 11, 2025

Hope it's still useful after almost 10 years :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants