Skip to content

dvgamerr-app/modpack-installer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

info.dvgamer@gmail.com

make golang gui installtion software from zip packafge

To create a GUI installation software for a Go program from a zip package, you can use a package like "fyne" which provides a simple way to create cross-platform desktop applications in Go.

Here's an example of how you can create a basic installer using Fyne:

goCopy code

package main import ( "archive/zip" "io" "os" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) func main() { a := app.New() w := a.NewWindow("Installer") // create a text label label := widget.NewLabel("Click the button below to install the program") // create a button that will extract the contents of the zip package to a specified directory button := widget.NewButton("Install", func() { zipReader, err := zip.OpenReader("program.zip") if err != nil { label.SetText("Error opening zip file") return } defer zipReader.Close() // specify the directory to extract the files to extractDir := "./program" for _, file := range zipReader.File { if file.FileInfo().IsDir() { os.MkdirAll(extractDir+"/"+file.Name, file.Mode()) continue } outFile, err := os.OpenFile(extractDir+"/"+file.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode()) if err != nil { label.SetText("Error extracting file: " + file.Name) return } defer outFile.Close() fileReader, err := file.Open() if err != nil { label.SetText("Error opening file: " + file.Name) return } defer fileReader.Close() if _, err = io.Copy(outFile, fileReader); err != nil { label.SetText("Error extracting file: " + file.Name) return } } label.SetText("Installation successful!") }) // create a container to hold the label and button content := container.NewVBox( label, button, ) // set the window content w.SetContent(content) // show the window w.ShowAndRun() }

This code will display a simple window with a label and a button. When the user clicks the button, the code will extract the contents of the "program.zip" file to a specified directory (in this case, "./program"). If the extraction is successful, the label will be updated to show a success message.

Note that this example is just a starting point and may need to be customized to meet your specific requirements.

info.dvgamer@gmail.com

and golang build with program.zip include to exe

To build a Go program that includes a zip package and produce a single executable file, you can use the "go-bindata" tool. This tool allows you to embed binary data (such as the contents of a zip file) directly into your Go executable.

Here are the steps to include a zip package in your Go program and build it as a single executable:

  1. First, install the "go-bindata" tool by running the following command:

    goCopy code

    go get -u github.com/go-bindata/go-bindata/...

  2. Create a new file called "assets.go" in your Go program directory. This file will contain the binary data of your zip package. Here's an example of what the file might look like:

    goCopy code

    package main import "github.com/go-bindata/go-bindata" //go:generate go-bindata -pkg main -o assets.go program.zip var programZip []byte func init() { programZip, _ = Asset("program.zip") }

    This code uses the "go-bindata" tool to generate a Go source file called "assets.go" that contains the binary data of the "program.zip" file. The "init" function then loads the binary data into a variable called "programZip".

  3. Build your Go program as usual, but include the "assets.go" file in the build command. For example:

    goCopy code

    go build -o myprogram.exe assets.go main.go

    This command will build your Go program as a Windows executable file called "myprogram.exe" and include the binary data of the "program.zip" file.

  4. You can now distribute the "myprogram.exe" file to users, and they can run it without needing the original "program.zip" file.

Note that this example is just a starting point and may need to be customized to meet your specific requirements. Also, keep in mind that embedding large amounts of binary data into your Go executable can significantly increase the size of the executable file.

info.dvgamer@gmail.com

and go build with icon.ico

To build a Go program with a custom icon in Windows, you can use the "rsrc" tool. This tool allows you to include a custom icon file (in .ico format) in your Go executable.

Here are the steps to build a Go program with a custom icon:

  1. First, install the "rsrc" tool by running the following command:

    goCopy code

    go get -u github.com/akavel/rsrc

  2. Create a new file called "icon.rc" in your Go program directory. This file will contain the resource definition for your icon file. Here's an example of what the file might look like:

    cssCopy code

    MAINICON ICON "icon.ico"

    This code defines a resource called "MAINICON" that uses the "icon.ico" file as its icon.

  3. Compile the "icon.rc" file into an object file by running the following command:

    cssCopy code

    rsrc -manifest myprogram.exe.manifest -ico icon.ico -o icon.syso

    This command will generate an object file called "icon.syso" that contains the compiled resource definition and the binary data of the "icon.ico" file.

    Note that the "-manifest" flag is optional and is used to specify a manifest file for your program. If your program doesn't have a manifest file, you can omit this flag.

  4. Build your Go program as usual, but include the "icon.syso" file in the build command. For example:

    goCopy code

    go build -o myprogram.exe -ldflags="-H windowsgui -linkmode internal" icon.syso main.go

    This command will build your Go program as a Windows executable file called "myprogram.exe" and include the "icon.syso" file as a resource.

    Note that the "-H windowsgui" flag is used to build a GUI application instead of a console application, and the "-linkmode internal" flag is used to link the resource object file into the executable.

  5. You can now distribute the "myprogram.exe" file with your custom icon.

Note that this example is just a starting point and may need to be customized to meet your specific requirements. Also, keep in mind that the "rsrc" tool is only available on Windows and cannot be used on other platforms.

ChatGPT Feb 13 Version. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your feedback will help us improve.

Export Markdown

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages