Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cratonica/2goarray
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: parvit/go2array
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 12 commits
  • 7 files changed
  • 2 contributors

Commits on Aug 5, 2022

  1. Copy the full SHA
    afa80ec View commit details
  2. Update README.md

    parvit authored Aug 5, 2022
    Copy the full SHA
    368219b View commit details
  3. Copy the full SHA
    0e8c461 View commit details

Commits on Aug 6, 2022

  1. Update README.md

    parvit authored Aug 6, 2022
    Copy the full SHA
    c87ba65 View commit details
  2. Copy the full SHA
    88157ed View commit details
  3. Copy the full SHA
    7de919c View commit details
  4. Copy the full SHA
    09322c5 View commit details

Commits on Aug 11, 2022

  1. Copy the full SHA
    6798a6d View commit details
  2. Copy the full SHA
    79667f6 View commit details

Commits on Jan 16, 2023

  1. * fix bad path on windows when directory harvest

    * added concurrent file read and optimized output to bytes
    * update README
    parvit committed Jan 16, 2023
    Copy the full SHA
    1b310ff View commit details

Commits on Jan 19, 2023

  1. * added default serialization of output to data file

    * added async flag to disable serialization
    parvit committed Jan 19, 2023
    Copy the full SHA
    4397ac4 View commit details

Commits on Jul 7, 2024

  1. fix darwin file creation

    Signed-off-by: Vittorio Parrella <vittorioparrella+1@gmail.com>
    parvit committed Jul 7, 2024
    Copy the full SHA
    447851b View commit details
Showing with 316 additions and 80 deletions.
  1. +0 −52 2goarray.go
  2. +1 −1 LICENSE
  3. +24 −8 README.md
  4. +3 −0 go.mod
  5. +288 −0 go2array.go
  6. +0 −12 unix.go
  7. +0 −7 windows.go
52 changes: 0 additions & 52 deletions 2goarray.go

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2013 Clint Caywood
Copyright (C) 2022 Vittorio Parrella

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
2goarray
go2array
========
A simple utility to encode a file (or any other data) into a Go byte slice.
Utility to encode a file (or a series of files) into a Go package.

Having [set up your Go environment](http://golang.org/doc/install), simply run

go get github.com/cratonica/2goarray
```
go get github.com/parvit/go2array
```

Then use by piping a file into the utility and capturing the output. You must provide a name for the generated slice symbol and package name. For example:
You must provide a name for the generated variables and the package name, the input files are specified as
parameters at the end. For example:

$GOPATH/bin/2goarray MyArray mypackage < myimage.png > myimage.go
```
go2array [-prefix <variablePrefix>] [-export] [-flat] [-nolist] [-package <packageName>] [-platform <platformName>] file1 [file2 ...]
```

This will output something like:
Default variabilePrefix is the value "binaries"

package mypackage
The output will be two files:

var MyArray []byte = []byte {
1. <variablePrefix>_filelist.go : That will contain a map with all the variables assigned to their original name
2. <variablePrefix>_data.go : Which will contain all the variables data

In <variablePrefix>_data.go you will find:
```
package <packageName>
// for each file, a variable is declared incrementing the index
var <variablePrefix>_<fileIndex> []byte = []byte {
0x49, 0x20, 0x63, 0x61, 0x6e, 0x27, 0x74, 0x20, 0x62, 0x65, 0x6c, 0x69,
0x65, 0x76, 0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x61, 0x63, 0x74, 0x75,
0x61, 0x6c, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64,
0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x20, 0x4b, 0x75, 0x64, 0x6f, 0x73,
0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x74,
0x68, 0x6f, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x2e, 0x0a,
}
```

## Contributors
- [Clint Caywood](https://github.com/cratonica)
- [Paul Vollmer](https://github.com/paulvollmer)
- [Vittorio Parrella](https://github.com/parvit)
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/parvit/go2array

go 1.16
Loading