-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2af33b6
Showing
8 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
FROM golang:1 | ||
|
||
# Avoid warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" | ||
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs | ||
# will be updated to match your local UID/GID (when using the dockerFile property). | ||
# See https://aka.ms/vscode-remote/containers/non-root-user for details. | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Configure apt, install packages and tools | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ | ||
# | ||
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed | ||
&& apt-get -y install git iproute2 procps lsb-release \ | ||
# | ||
# Install Go tools w/module support | ||
&& mkdir -p /tmp/gotools \ | ||
&& cd /tmp/gotools \ | ||
&& GO111MODULE=on go get -v golang.org/x/tools/gopls@latest 2>&1 \ | ||
&& GO111MODULE=on go get -v \ | ||
honnef.co/go/tools/...@latest \ | ||
golang.org/x/tools/cmd/gorename@latest \ | ||
golang.org/x/tools/cmd/goimports@latest \ | ||
golang.org/x/tools/cmd/guru@latest \ | ||
golang.org/x/lint/golint@latest \ | ||
github.com/mdempsky/gocode@latest \ | ||
github.com/cweill/gotests/...@latest \ | ||
github.com/haya14busa/goplay/cmd/goplay@latest \ | ||
github.com/sqs/goreturns@latest \ | ||
github.com/josharian/impl@latest \ | ||
github.com/davidrjenni/reftools/cmd/fillstruct@latest \ | ||
github.com/ramya-rao-a/go-outline@latest \ | ||
github.com/acroca/go-symbols@latest \ | ||
github.com/godoctor/godoctor@latest \ | ||
github.com/rogpeppe/godef@latest \ | ||
github.com/zmb3/gogetdoc@latest \ | ||
github.com/fatih/gomodifytags@latest \ | ||
github.com/mgechev/revive@latest \ | ||
github.com/go-delve/delve/cmd/dlv@latest 2>&1 \ | ||
# | ||
# Install Go tools w/o module support | ||
&& go get -v github.com/alecthomas/gometalinter \ | ||
github.com/uudashr/gopkgs/cmd/gopkgs 2>&1 \ | ||
# | ||
# Install gocode-gomod | ||
&& go get -x -d github.com/stamblerre/gocode 2>&1 \ | ||
&& go build -o gocode-gomod github.com/stamblerre/gocode \ | ||
&& mv gocode-gomod $GOPATH/bin/ \ | ||
# | ||
# Install golangci-lint | ||
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin 2>&1 \ | ||
# | ||
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. | ||
&& groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
# [Optional] Add sudo support | ||
&& apt-get install -y sudo \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME \ | ||
# Add write permission for /go/pkg | ||
&& chmod -R a+rwX /go/pkg \ | ||
# | ||
# Clean up | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* /go/src /tmp/gotools | ||
|
||
# Update this to "on" or "off" as appropriate | ||
ENV GO111MODULE=auto | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND=dialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "Go DevContainer", | ||
"dockerFile": "Dockerfile", | ||
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | ||
|
||
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure | ||
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost. | ||
"appPort": [9000], | ||
|
||
// Use 'settings' to set *default* container specific settings.json values on container create. | ||
// You can edit these settings after create using File > Preferences > Settings > Remote. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"go.gopath": "/go", | ||
"go.inferGopath": true, | ||
"go.useLanguageServer": true | ||
}, | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
// "postCreateCommand": "go version", | ||
|
||
// Comment out the next line to run as root | ||
"remoteUser": "vscode", | ||
|
||
// Add the IDs of extensions you want installed when the container is created in the array below. | ||
"extensions": [ | ||
"ms-vscode.go" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
scripts/settings.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 MrFlutters / Hotaru | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Morrowind.esm | ||
Tribunal.esm | ||
Bloodmoon.esm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
prepareBuild(){ | ||
echo -n "Preparing Build Enviroment...\n" | ||
rm -rf ./build | ||
mkdir -p ../build ./build/windows ./build/linux | ||
echo -n "Done\n" | ||
} | ||
|
||
# Build Linux | ||
buildLinux(){ | ||
echo -n "Building Linux Binary...\n" | ||
go build -o ../build/linux/TES3MP-CRC32 ../src/main.go | ||
echo -n "Done\n" | ||
} | ||
buildWindows(){ | ||
echo -n "Building Windows Binary...\n" | ||
GOOS=windows GOARCH=386 go build -o ../build/windows/TES3MP-CRC32.exe ../src/main.go | ||
echo -n "Done\n" | ||
} | ||
|
||
prepareBuild | ||
buildLinux | ||
buildWindows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
. ./settings.sh | ||
|
||
github-release info -u $user -r $repo | ||
|
||
github-release upload \ | ||
--user $user \ | ||
--repo $repo \ | ||
--tag $tag \ | ||
--name "$repo-Linux" \ | ||
--file ../build/linux/$buildname | ||
|
||
github-release upload \ | ||
--user $user \ | ||
--repo $repo \ | ||
--tag $tag \ | ||
--name "$repo-Windows.exe" \ | ||
--file ../build/windows/$buildname.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"encoding/hex" | ||
"flag" | ||
"fmt" | ||
"hash/crc32" | ||
"io" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// https://mrwaggel.be/post/generate-crc32-hash-of-a-file-in-golang-turorial/ | ||
func hashFileCRC32(filePath string, polynomial uint32) (string, error) { | ||
//Initialize an empty return string now in case an error has to be returned | ||
var returnCRC32String string | ||
|
||
//Open the fhe file located at the given path and check for errors | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
return returnCRC32String, err | ||
} | ||
|
||
//Tell the program to close the file when the function returns | ||
defer file.Close() | ||
|
||
//Create the table with the given polynomial | ||
tablePolynomial := crc32.MakeTable(polynomial) | ||
|
||
//Open a new hash interface to write the file to | ||
hash := crc32.New(tablePolynomial) | ||
|
||
//Copy the file in the interface | ||
if _, err := io.Copy(hash, file); err != nil { | ||
return returnCRC32String, err | ||
} | ||
|
||
//Generate the hash | ||
hashInBytes := hash.Sum(nil)[:] | ||
|
||
//Encode the hash to a string | ||
returnCRC32String = hex.EncodeToString(hashInBytes) | ||
|
||
//Return the output | ||
return returnCRC32String, nil | ||
} | ||
|
||
func main() { | ||
loadOrderFlag := flag.String("loadOrder", "", "Load order file") | ||
dataFileFlag := flag.String("dataFiles", "", "Data Files Directory") | ||
|
||
flag.Parse() | ||
|
||
flag.VisitAll(func(f *flag.Flag) { | ||
if f.Value.String() == "" { | ||
fmt.Println(os.Args[0] + " --loadOrder ./loadOrder.txt" + " --dataFiles \"/home/tes3mp/Data Files\"") | ||
os.Exit(1) | ||
} | ||
}) | ||
|
||
loadOrder, loadOrdererr := os.Open(*loadOrderFlag) | ||
|
||
if loadOrdererr != nil { | ||
log.Fatal(loadOrdererr) | ||
} | ||
defer loadOrder.Close() | ||
|
||
scanner := bufio.NewScanner(loadOrder) | ||
for scanner.Scan() { | ||
file := *dataFileFlag + scanner.Text() | ||
hash, err := hashFileCRC32(file, 0xedb88320) | ||
if err == nil { | ||
fmt.Println(filepath.Base(file) + ": " + "0x" + strings.ToUpper(hash)) | ||
} | ||
} | ||
|
||
if err := scanner.Err(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |