├── BUILDBIT.txt ├── diff └── placeholder ├── git └── placeholder ├── go └── placeholder ├── liteide └── placeholder ├── mercurial └── placeholder ├── workspace ├── GetPackages.txt ├── Packages.txt ├── BuildVersion.txt ├── __Command Prompt.cmd ├── src │ └── hello │ │ ├── icon.ico │ │ ├── hello.go │ │ ├── versioninfo.json │ │ └── hello_test.go ├── bin │ └── goversioninfo.exe ├── _List.cmd ├── _Document.cmd ├── _Clean.cmd ├── _Format.cmd ├── _Vet.cmd ├── _Fix.cmd ├── _FixDiff.cmd ├── _Get.cmd ├── _Lint.cmd ├── _Build.cmd ├── _Generate.cmd ├── _GetUpdate.cmd ├── _GetInstall.cmd ├── _Install.cmd ├── _Test.cmd ├── _TestBenchmark.cmd ├── _BuildRun.cmd ├── _BuildRaceDetector.cmd ├── _Embed.cmd ├── _TestCoverage.cmd └── __Global.cmd ├── liteide_config ├── config │ ├── global.ini │ └── liteide.ini ├── system32.env ├── system64.env └── jrepl.bat ├── doc ├── README.txt ├── NOTICE.txt ├── LICENSE.txt └── CHANGELOG.txt ├── LICENSE ├── LiteIDE.cmd └── README.md /BUILDBIT.txt: -------------------------------------------------------------------------------- 1 | 64 -------------------------------------------------------------------------------- /diff/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /git/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /liteide/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mercurial/placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /workspace/GetPackages.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /workspace/Packages.txt: -------------------------------------------------------------------------------- 1 | hello -------------------------------------------------------------------------------- /workspace/BuildVersion.txt: -------------------------------------------------------------------------------- 1 | 1.0.0.0 -------------------------------------------------------------------------------- /liteide_config/config/global.ini: -------------------------------------------------------------------------------- 1 | [LiteIDE] 2 | StoreLocal=true 3 | -------------------------------------------------------------------------------- /liteide_config/config/liteide.ini: -------------------------------------------------------------------------------- 1 | [General] 2 | side_side_hide=false 3 | -------------------------------------------------------------------------------- /workspace/__Command Prompt.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CALL __Global.cmd 4 | 5 | cmd -------------------------------------------------------------------------------- /workspace/src/hello/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephspurrier/golang-portable-windows/HEAD/workspace/src/hello/icon.ico -------------------------------------------------------------------------------- /workspace/bin/goversioninfo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephspurrier/golang-portable-windows/HEAD/workspace/bin/goversioninfo.exe -------------------------------------------------------------------------------- /doc/README.txt: -------------------------------------------------------------------------------- 1 | Thanks for downloading! 2 | 3 | The most current download can be found at: 4 | * https://github.com/josephspurrier/golang-portable-windows -------------------------------------------------------------------------------- /workspace/_List.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CALL __Global.cmd 4 | 5 | ECHO *** Go List *** 6 | ECHO List outputs the packages named by the import paths, one per line. 7 | ECHO. 8 | 9 | go list ./... 10 | ECHO. 11 | 12 | PAUSE -------------------------------------------------------------------------------- /workspace/_Document.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CALL __Global.cmd 4 | 5 | ECHO *** Godoc *** 6 | ECHO Godoc extracts and generates documentation for Go programs 7 | ECHO. 8 | 9 | ECHO Web browser opened to http://localhost:6060 10 | start http://localhost:6060 11 | godoc -http=:6060 12 | ECHO. -------------------------------------------------------------------------------- /workspace/_Clean.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Clean *** 7 | ECHO Clean removes object files from package source directories 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Cleaning: !PACKAGE! 16 | go clean -i !PACKAGE! 17 | ECHO. 18 | ) 19 | 20 | ) -------------------------------------------------------------------------------- /workspace/_Format.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Gofmt *** 7 | ECHO Gofmt formats Go programs 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Formatting: !PACKAGE! 16 | gofmt -s -w "%GOPATH%\src\!PACKAGE!" 17 | ECHO. 18 | ) 19 | 20 | ) 21 | 22 | PAUSE -------------------------------------------------------------------------------- /workspace/_Vet.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Vet *** 7 | ECHO Vet examines Go source code and reports suspicious constructs 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Vetting: !PACKAGE! 16 | go vet !PACKAGE! 17 | ECHO. 18 | ) 19 | 20 | ) 21 | 22 | PAUSE -------------------------------------------------------------------------------- /workspace/_Fix.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | CALL __Global.cmd 4 | 5 | ECHO *** Go Fix *** 6 | ECHO Fix finds Go programs that use old APIs and rewrites them to use newer ones 7 | ECHO. 8 | 9 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 10 | SET PACKAGE=%%A 11 | SET FIRSTLETTER=!PACKAGE:~0,1! 12 | 13 | IF NOT !FIRSTLETTER!==# ( 14 | ECHO Fixing: !PACKAGE! 15 | go tool fix "%GOPATH%\src\!PACKAGE!" 16 | ECHO. 17 | ) 18 | 19 | ) 20 | 21 | PAUSE -------------------------------------------------------------------------------- /workspace/_FixDiff.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | CALL __Global.cmd 4 | 5 | ECHO *** Go Fix *** 6 | ECHO Fix finds Go programs that use old APIs and rewrites them to use newer ones 7 | ECHO. 8 | 9 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 10 | SET PACKAGE=%%A 11 | SET FIRSTLETTER=!PACKAGE:~0,1! 12 | 13 | IF NOT !FIRSTLETTER!==# ( 14 | ECHO Fixing: !PACKAGE! 15 | go tool fix -diff "%GOPATH%\src\!PACKAGE!" 16 | ECHO. 17 | ) 18 | 19 | ) 20 | 21 | PAUSE -------------------------------------------------------------------------------- /workspace/_Get.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Get *** 7 | ECHO Get downloads the packages named by the import paths, along with their dependencies. 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (GetPackages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Getting: !PACKAGE! 16 | go get -d !PACKAGE! 17 | ECHO. 18 | 19 | IF !ERRORLEVEL! NEQ 0 PAUSE 20 | ) 21 | 22 | ) -------------------------------------------------------------------------------- /workspace/_Lint.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Golint *** 7 | ECHO Lint prints out style mistakes 8 | ECHO. 9 | 10 | go get github.com/golang/lint/golint 11 | 12 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 13 | SET PACKAGE=%%A 14 | SET FIRSTLETTER=!PACKAGE:~0,1! 15 | 16 | IF NOT !FIRSTLETTER!==# ( 17 | ECHO Linting: !PACKAGE! 18 | cd "%GOPATH%\src\!PACKAGE!" 19 | golint ./... 20 | ECHO. 21 | ) 22 | 23 | ) 24 | 25 | PAUSE 26 | -------------------------------------------------------------------------------- /workspace/_Build.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Build *** 7 | ECHO Build compiles packages and dependencies 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Building: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | go build -v %LDFLAGS% !PACKAGE! 18 | ECHO. 19 | 20 | IF !ERRORLEVEL! NEQ 0 PAUSE 21 | ) 22 | 23 | ) 24 | -------------------------------------------------------------------------------- /workspace/_Generate.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Generate *** 7 | ECHO Runs commands described by directives within existing files 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Building: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | go generate 18 | ECHO. 19 | 20 | IF !ERRORLEVEL! NEQ 0 PAUSE 21 | ) 22 | 23 | ) 24 | -------------------------------------------------------------------------------- /workspace/_GetUpdate.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Get *** 7 | ECHO Get force downloads the packages named by the import paths, along with their dependencies. 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (GetPackages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Getting: !PACKAGE! 16 | go get -d -u !PACKAGE! 17 | ECHO. 18 | 19 | IF !ERRORLEVEL! NEQ 0 PAUSE 20 | ) 21 | 22 | ) -------------------------------------------------------------------------------- /workspace/_GetInstall.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Get *** 7 | ECHO Get downloads and installs the packages named by the import paths, along with their dependencies. 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (GetPackages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Getting: !PACKAGE! 16 | go get !PACKAGE! 17 | ECHO. 18 | 19 | IF !ERRORLEVEL! NEQ 0 PAUSE 20 | ) 21 | 22 | ) -------------------------------------------------------------------------------- /workspace/_Install.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Install *** 7 | ECHO Installs the packages named by the import paths 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Installing: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | go install -v %LDFLAGS% !PACKAGE! 18 | ECHO. 19 | 20 | IF !ERRORLEVEL! NEQ 0 PAUSE 21 | ) 22 | 23 | ) 24 | -------------------------------------------------------------------------------- /workspace/_Test.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Test *** 7 | ECHO Test runs package tests 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Testing: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | 18 | IF %BUILDBIT%==32 ( 19 | go test !PACKAGE! -cover 20 | ) ELSE ( 21 | go test !PACKAGE! -race -cover 22 | ) 23 | 24 | ECHO. 25 | ) 26 | 27 | ) 28 | 29 | PAUSE -------------------------------------------------------------------------------- /liteide_config/system32.env: -------------------------------------------------------------------------------- 1 | # portable config for windows 386 2 | 3 | WORKROOT= 4 | GOROOT=%WORKROOT%\go 5 | GOPATH=%WORKROOT%\workspace 6 | GIT=%WORKROOT%\git\bin 7 | GIT_SSL_NO_VERIFY=1 8 | MERCURIAL=%WORKROOT%\mercurial 9 | DIFF=%WORKROOT%\diff\bin 10 | PATH=c:\mingw32\bin;%GOROOT%\bin32;%GOPATH%\bin;%GIT%;%MERCURIAL%;%DIFF%;%PATH% 11 | 12 | GOARCH=386 13 | GOOS=windows 14 | CGO_ENABLED=1 15 | 16 | LITEIDE_GDB=gdb 17 | LITEIDE_MAKE=mingw32-make 18 | LITEIDE_TERM=%COMSPEC% 19 | LITEIDE_TERMARGS= 20 | LITEIDE_EXEC=%COMSPEC% 21 | LITEIDE_EXECOPT=/C 22 | -------------------------------------------------------------------------------- /workspace/_TestBenchmark.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Test *** 7 | ECHO Test runs package tests 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Testing: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | 18 | IF %BUILDBIT%==32 ( 19 | go test !PACKAGE! -bench=. 20 | ) ELSE ( 21 | go test !PACKAGE! -race -bench=. 22 | ) 23 | 24 | ECHO. 25 | ) 26 | 27 | ) 28 | 29 | PAUSE -------------------------------------------------------------------------------- /liteide_config/system64.env: -------------------------------------------------------------------------------- 1 | # portable config for windows amd64 2 | 3 | WORKROOT= 4 | GOROOT=%WORKROOT%\go 5 | GOPATH=%WORKROOT%\workspace 6 | GIT=%WORKROOT%\git\bin 7 | GIT_SSL_NO_VERIFY=1 8 | MERCURIAL=%WORKROOT%\mercurial 9 | DIFF=%WORKROOT%\diff\bin 10 | PATH=c:\mingw64\bin;%GOROOT%\bin64;%GOPATH%\bin;%GIT%;%MERCURIAL%;%DIFF%;%PATH% 11 | 12 | GOARCH=amd64 13 | GOOS=windows 14 | CGO_ENABLED=1 15 | 16 | LITEIDE_GDB=gdb64 17 | LITEIDE_MAKE=mingw32-make 18 | LITEIDE_TERM=%COMSPEC% 19 | LITEIDE_TERMARGS= 20 | LITEIDE_EXEC=%COMSPEC% 21 | LITEIDE_EXECOPT=/C 22 | -------------------------------------------------------------------------------- /workspace/_BuildRun.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Build then Run *** 7 | ECHO Run compiles and runs the main package 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Running: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | 18 | for %%F in (!PACKAGE!) do ( 19 | go build -v %LDFLAGS% 20 | %%~nxF.exe 21 | ECHO. 22 | 23 | IF !ERRORLEVEL! NEQ 0 PAUSE 24 | ) 25 | 26 | ) 27 | 28 | ) -------------------------------------------------------------------------------- /workspace/_BuildRaceDetector.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Build *** 7 | ECHO Build compiles packages and dependencies with race condition detector 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Building: !PACKAGE! 16 | cd "%GOPATH%\src\!PACKAGE!" 17 | DEL /Q /F *.syso > nul 2>&1 18 | go build -v -race %LDFLAGS% !PACKAGE! 19 | ECHO. 20 | 21 | IF !ERRORLEVEL! NEQ 0 PAUSE 22 | ) 23 | 24 | ) 25 | -------------------------------------------------------------------------------- /doc/NOTICE.txt: -------------------------------------------------------------------------------- 1 | This product includes software developed by 2 | the Joseph Spurrier (http://www.josephspurrier.com). 3 | 4 | This product includes software developed by 5 | The Go Authors (https://golang.org). 6 | 7 | This product includes software developed by 8 | Git for Windows (http://msysgit.github.io). 9 | 10 | This product includes software developed by 11 | EasyMercurial (http://easyhg.org/). 12 | 13 | This product includes software developed by 14 | DiffUtils for Windows (http://gnuwin32.sourceforge.net/packages/diffutils.htm). 15 | 16 | This product includes software developed by 17 | visualfc (https://github.com/visualfc/liteide). -------------------------------------------------------------------------------- /workspace/_Embed.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Goversioninfo *** 7 | ECHO Creates a syso file with version information and an icon 8 | ECHO Go Build will automatically embed the resource 9 | ECHO Icon should be named: icon.ico 10 | ECHO Version Info should be named: versioninfo.json 11 | ECHO Code available here: https://github.com/josephspurrier/goversioninfo 12 | ECHO. 13 | 14 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 15 | SET PACKAGE=%%A 16 | SET FIRSTLETTER=!PACKAGE:~0,1! 17 | 18 | IF NOT !FIRSTLETTER!==# ( 19 | ECHO Creating SYSO File: !PACKAGE! 20 | CD "%GOPATH%\src\!PACKAGE!" 21 | goversioninfo -icon=icon.ico 22 | ECHO. 23 | ) 24 | 25 | ) -------------------------------------------------------------------------------- /workspace/_TestCoverage.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | CALL __Global.cmd 5 | 6 | ECHO *** Go Test *** 7 | ECHO Test runs package tests 8 | ECHO. 9 | 10 | FOR /F "tokens=*" %%A IN (Packages.txt) DO ( 11 | SET PACKAGE=%%A 12 | SET FIRSTLETTER=!PACKAGE:~0,1! 13 | 14 | IF NOT !FIRSTLETTER!==# ( 15 | ECHO Testing: !PACKAGE! 16 | 17 | IF %BUILDBIT%==32 ( 18 | go test -coverprofile="%GOPATH%\test.tmp" -cover !PACKAGE! 19 | ) ELSE ( 20 | go test -coverprofile="%GOPATH%\test.tmp" -race -cover !PACKAGE! 21 | ) 22 | 23 | ECHO. 24 | 25 | IF EXIST "%GOPATH%\test.tmp" ( 26 | ECHO *** Gotool *** 27 | ECHO Tool generates an html coverage map - web browser with test coverage 28 | go tool cover -html="%GOPATH%\test.tmp" 29 | DEL /F /Q "%GOPATH%\test.tmp" 30 | ) ELSE ( 31 | ECHO Skipping coverage map 32 | ) 33 | 34 | ECHO. 35 | 36 | ) 37 | ) 38 | 39 | PAUSE -------------------------------------------------------------------------------- /workspace/src/hello/hello.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Joseph Spurrier 2 | // Author: Joseph Spurrier (http://josephspurrier.com) 3 | // License: http://www.apache.org/licenses/LICENSE-2.0.html 4 | 5 | //go:generate goversioninfo -icon=icon.ico 6 | 7 | /* 8 | Package hello does something here. 9 | 10 | Heading 1 11 | 12 | Body text 13 | Preformatted code is indented 14 | May span multiple lines 15 | 16 | */ 17 | package main 18 | 19 | import ( 20 | "flag" 21 | "fmt" 22 | "os" 23 | ) 24 | 25 | var ( 26 | Version string 27 | BuildDate string 28 | ) 29 | 30 | func init() { 31 | flag.Usage = func() { 32 | fmt.Fprintf(os.Stderr, "Version: %s\n", Version) 33 | fmt.Fprintf(os.Stderr, "Build Date: %s\n", BuildDate) 34 | fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) 35 | flag.PrintDefaults() 36 | } 37 | flag.Parse() 38 | } 39 | 40 | func main() { 41 | fmt.Println("Hello") 42 | } 43 | -------------------------------------------------------------------------------- /workspace/src/hello/versioninfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "FixedFileInfo": 3 | { 4 | "FileVersion": { 5 | "Major": 1, 6 | "Minor": 0, 7 | "Patch": 0, 8 | "Build": 0 9 | }, 10 | "ProductVersion": { 11 | "Major": 1, 12 | "Minor": 0, 13 | "Patch": 0, 14 | "Build": 0 15 | }, 16 | "FileFlagsMask": "3f", 17 | "FileFlags ": "00", 18 | "FileOS": "040004", 19 | "FileType": "01", 20 | "FileSubType": "00" 21 | }, 22 | "StringFileInfo": 23 | { 24 | "Comments": "", 25 | "CompanyName": "", 26 | "FileDescription": "", 27 | "FileVersion": "", 28 | "InternalName": "", 29 | "LegalCopyright": "", 30 | "LegalTrademarks": "", 31 | "OriginalFilename": "", 32 | "PrivateBuild": "", 33 | "ProductName": "", 34 | "ProductVersion": "v1.0.0.0", 35 | "SpecialBuild": "" 36 | }, 37 | "VarFileInfo": 38 | { 39 | "Translation": { 40 | "LangID": "0409", 41 | "CharsetID": "04B0" 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /workspace/__Global.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | FOR %%a in ("%CD%\..") DO SET WORKROOT=%%~fa 4 | SET GOROOT=%WORKROOT%\go 5 | SET GOPATH=%CD% 6 | SET GIT=%WORKROOT%\git\bin 7 | SET GIT_SSL_NO_VERIFY=1 8 | SET MERCURIAL=%WORKROOT%\mercurial 9 | SET DIFF=%WORKROOT%\diff\bin 10 | SET /P BUILDBIT=<..\BUILDBIT.txt 11 | SET PATH=c:\mingw%BUILDBIT%\bin;%GOROOT%\bin%BUILDBIT%;%GOPATH%\bin;%GIT%;%MERCURIAL%;%DIFF%;%PATH% 12 | 13 | FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B 14 | FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B 15 | FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B 16 | FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B 17 | SET DATE=%yyyy%%mm%%dd% 18 | SET TIME=%TIME: =0% 19 | SET TIME=%TIME::=.% 20 | SET TIME=%TIME:.=% 21 | SET TIMESTAMP=%DATE%%TIME% 22 | 23 | FOR /f "delims=" %%x in (BuildVersion.txt) DO SET VERSION=%%x 24 | 25 | SET LDFLAGS=-ldflags "-X main.Version=%VERSION% -X main.BuildDate=%TIMESTAMP%" -------------------------------------------------------------------------------- /workspace/src/hello/hello_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Joseph Spurrier 2 | // Author: Joseph Spurrier (http://josephspurrier.com) 3 | // License: http://www.apache.org/licenses/LICENSE-2.0.html 4 | 5 | // Package main_test performs testing on main package 6 | package main_test 7 | 8 | import ( 9 | "fmt" 10 | "testing" 11 | ) 12 | 13 | // Prepare tests 14 | /*func TestMain(m *testing.M) { 15 | }*/ 16 | 17 | // Assertion test 18 | func TestOutput(t *testing.T) { 19 | // Function to easily test expected values 20 | assertEqual := func(expectedValue interface{}, actualValue interface{}) { 21 | if actualValue != expectedValue { 22 | t.Errorf("\n got: %v\nwant: %v", actualValue, expectedValue) 23 | } 24 | } 25 | 26 | val := "Hello" 27 | assertEqual("Hello", val) 28 | } 29 | 30 | // Benchmark test 31 | func BenchmarkHello10(b *testing.B) { 32 | for n := 0; n < b.N; n++ { 33 | fmt.Println("Hello") 34 | } 35 | } 36 | 37 | // Race condition test 38 | func TestGo(t *testing.T) { 39 | go fmt.Println("Hello") 40 | } 41 | 42 | // Example code test 43 | func ExampleOutput() { 44 | fmt.Println("Hello") 45 | // Output: Hello 46 | } 47 | -------------------------------------------------------------------------------- /doc/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joseph Spurrier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joseph Spurrier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /doc/CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Current changelog is available here: https://github.com/josephspurrier/golang-portable-windows/releases 2 | 3 | ------------------------------------------------------------------------------- 4 | 5 | v1.6.0 (2015-03-11) 6 | ------------------- 7 | * Added _BuildRun.cmd 8 | * Updated to Go v1.4.2 AMD64 9 | 10 | v1.5.1 (2015-02-14) 11 | ------------------- 12 | * Added the ability to comment out packages in the .txt files 13 | * Removed dead code from batch scripts 14 | * Updated boilerplate project name from start to hello 15 | * Updated boilerplate and _Embed.cmd to include goversioninfo parameters 16 | 17 | v1.5.0 (2015-02-01) 18 | ------------------- 19 | * Added EasyMercurial v1.3.0 20 | * Updated goversioninfo.exe from https://github.com/josephspurrier/goversioninfo 21 | 22 | v1.4.0 (2015-01-19) 23 | ------------------- 24 | * Updated scripts to use Packages.txt instead of the go list command for faster building 25 | * Added DiffUtils v2.8.7-1 26 | * Added goversioninfo.exe from https://github.com/josephspurrier/goversioninfo 27 | * Added _FixDiff.cmd, _Format.cmd, _Generate.cmd, and _GetInstall.cmd 28 | * Removed gofmt from tests 29 | 30 | v1.3.0 (2015-01-16) 31 | ------------------- 32 | * Updated to Go v1.4.1 AMD64 33 | 34 | v1.2.0 (2015-01-04) 35 | ------------------- 36 | * Updated a few scripts to only PAUSE on errors 37 | * Added benchmark script and boilerplate code 38 | 39 | v1.1.0 (2015-01-02) 40 | ------------------- 41 | * Added _Get.cmd 42 | * Added GetPackages.txt 43 | * Updated scripts with unused variables 44 | 45 | v1.0.0 (2014-12-31) 46 | ------------------- 47 | * Added Go v1.4 AMD64 (Programming Language) (2014-12-10) 48 | * Added msysGit Net Install v1.9.4 (Version Control System) (2014-09-29 Preview) 49 | * Added one-click use of go build, go clean, godoc, go tool fix, go install, golint, go list, go test, and go vet 50 | * Added main package and main_test package 51 | * Added code for Version and BuildDate flags 52 | * Added formatting help for documentation in main package 53 | * Added sample tests for main_test package -------------------------------------------------------------------------------- /LiteIDE.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | Setlocal EnableDelayedExpansion 3 | 4 | ECHO Starting up LiteIDE with the correct paths... 5 | 6 | REM Get the BUILDBIT of 32 or 64 7 | SET /P BUILDBIT=> liteide_config\config\liteide2.ini 29 | ECHO [session]>> liteide_config\config\liteide2.ini 30 | ECHO default_folderList=%ROOTDIR%/workspace/src>> liteide_config\config\liteide2.ini 31 | ECHO.>> liteide_config\config\liteide2.ini 32 | ECHO [FileManager]>> liteide_config\config\liteide2.ini 33 | ECHO initpath=%ROOTDIR%/workspace/src>> liteide_config\config\liteide2.ini 34 | REM ECHO.>> liteide_config\config\liteide2.ini 35 | REM ECHO [golangdoc]>> liteide_config\config\liteide2.ini 36 | REM ECHO goroot=!ROOTDIR2!\\go>> liteide_config\config\liteide2.ini 37 | COPY /Y liteide_config\config\global.ini liteide\share\liteide\liteapp\config\global.ini 38 | COPY /Y liteide_config\config\liteide2.ini liteide\share\liteide\liteapp\config\liteide.ini 39 | DEL liteide_config\config\liteide2.ini 40 | 41 | ECHO Delete this file to reset LiteIDE to the default settings the next time you run LiteIDE.cmd > liteide_config\locked.txt 42 | ) ELSE ( 43 | REM Find the name of the last root folder 44 | SET ENDING=THISWONTREPLACE 45 | for /f "tokens=*" %%a in (liteide\share\liteide\liteapp\config\liteide.ini) do ( 46 | SET P=%%a 47 | SET BEGINNING=!P:~0,19! 48 | IF "!BEGINNING!"=="default_folderList=" ( 49 | SET ENDING=!P:~19! 50 | SET ENDING=!ENDING:~0,-14! 51 | SET ENDING2=!ENDING:/=\\! 52 | ) 53 | ) 54 | 55 | REM Replace the last root folder name with the new root folder name in the liteide config 56 | CALL liteide_config\jrepl.bat "!ENDING!" "%ROOTDIR%" /F liteide\share\liteide\liteapp\config\liteide.ini /O - 57 | CALL liteide_config\jrepl.bat "!ENDING2!" "%ROOTDIR2%" /F liteide\share\liteide\liteapp\config\liteide.ini /O - 58 | CALL liteide_config\jrepl.bat "!ENDING2:~4!" "%ROOTDIR3:~3%" /F liteide\share\liteide\liteapp\config\liteide.ini /O - 59 | 60 | REM Replace the last root folder name with the new root folder name in the environment paths 61 | CALL liteide_config\jrepl.bat "!ENDING2!" "%ROOTDIR3%" /F liteide\share\liteide\liteenv\system.env /O - 62 | ) 63 | 64 | REM Start LiteIDE 65 | start liteide\bin\liteide.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | golang-portable-windows 2 | ======================= 3 | 4 | Go Programming Language - Portable Environment for Windows 5 | 6 | This project allows you to set up a full Go environment in 30 seconds so you can start building Go applications. There is no installation necessary, just extract to your desktop or a portable drive. You can build Go applications using the included portable LiteIDE, the easy-to-use batch scripts, or from plain command prompt. The Go binaries are included so you don't have to build the Go language itself. 7 | 8 | The releases are now generated using this tool [goappmation](https://github.com/josephspurrier/goappmation/tree/master/project/Go%20Portable). 9 | 10 | ## Download 11 | The latest 32-bit and 64-bit stable release is [here](https://github.com/josephspurrier/golang-portable-windows/releases) (2018-2-20). Previous releases were split into separate 32-bit and 64-bit downloads. It's easier to maintain a single version which allows you to compile either 32-bit or 64-bit by updating the BUILDBIT.txt file. Simply change the text to either 32 or 64 (default) and both LiteIDE and the batch scripts will build for that architecture. For LiteIDE, you also have to delete \liteide_config\locked.txt and then restart it. 12 | 13 | The repository does not contain most of the binaries. Be sure to download the latest release which includes the binaries for Go, LiteIDE, Git, Mercurial, and Diff. 14 | 15 | ## Overview 16 | 17 | If you sat down at your friends computer, to get Go up and running: 18 | 19 | * Download the latest zip release 20 | * Extract to a folder 21 | * Double click LiteIDE.cmd 22 | 23 | It's that simple. 24 | 25 | ## Applications 26 | 27 | Included is all the original files from [go1.10.windows-xxx.zip](http://golang.org/dl/), [LiteIDE X33.2](https://github.com/visualfc/liteide), [msysGit](https://msysgit.github.io/), [EasyMercurial](http://easyhg.org/), and [DiffUtils](http://gnuwin32.sourceforge.net/packages/diffutils.htm). No changes have been made to any of the files, just extracted to separate folders. The only exception is msysGit which has these additional files from the full portable install: basename.txt, tr.exe, git-pull, git-sh-i18n, git-merge, and git-parse-remote. 28 | 29 | # Using LiteIDE 30 | 31 | Just double click LiteIDE.cmd to start up a portable version of LiteIDE. The GOPATH will automatically be set using a local configuration file. If you move your project to another computer, run LiteIDE.cmd on the new computer to change all the paths inside liteide.ini to the new path. If you want to start from a fresh LiteIDE configuration, just delete \liteide_config\locked.txt and run LiteIDE.cmd. 32 | 33 | # Using Batch Scripts 34 | 35 | If you don't want to use LiteIDE to build your Go applications, you can use the batch scripts in \workspace. All the scripts call __Global.cmd first to set the environment variables and paths. All the scripts are designed to work with the current file structure so no absolute paths are hard coded which makes the scripts very flexible. The "go run" command is not used in any of the scripts because it runs from a temporary location that requires you to add a firewall exception each time it is run - instead "go build" is used to build the app and then run normally. The only differences between the 32-bit and 64-bit releases are _BuildRaceDetector.cmd is removed in 32-bit and _Test.cmd, _TestBenchmark.cmd, and _TestCoverage.cmd do not have the -race flag in 32-bit. Go 32-bit does not support race detection. 36 | 37 | ``` 38 | __Command Prompt.cmd - Opens a command prompt 39 | __Global.cmd - Called by all the scripts to set the environment variables and paths 40 | _Build.cmd - Builds all apps with a main() function in respective directories, sets Version and BuildDate inside app 41 | _BuildRaceDetector.cmd - Same as _Build.cmd, but includes -race flag which detects race conditions (size of .exe is greatly increased, not for Production) 42 | _BuildRun.cmd - Same as _Build.cmd, but runs the app as well 43 | _Clean.cmd - Removes object files from package source directories and corresponding binary 44 | _Document.cmd - Runs web server and opens a browser to a local version of the documentation for the application 45 | _Embed.cmd - Creates a syso file with version information (versioninfo.json) and an icon (icon.ico) 46 | _Fix.cmd - Finds lines of code that use old APIs and makes corrections 47 | _FixDiff.cmd - Finds lines of code that use old APIs and shows diffs to use newer APIs 48 | _Format.cmd - Formats lines of code correctly 49 | _Generate.cmd - Runs commands described by directives within existing files 50 | _Get.cmd - Downloads the packages named by the import paths 51 | _GetInstall.cmd - Downloads and installs the packages named by the import paths 52 | _GetUpdate.cmd - Downloads and force updates the packages named by the import paths 53 | _Install.cmd - Installs the packages in the /bin directory (will create automatically) 54 | _Lint.cmd - Installs Lint and then prints out style mistakes 55 | _List.cmd - Outputs all the packages 56 | _Test.cmd - Runs all package tests and outputs code coverage as well as any race conditions 57 | _TestBenchmark.cmd - Runs all package tests and outputs all benchmarks 58 | _TestCoverage.cmd - Same as _Test.cmd, but then opens a web browser to a local version of the code coverage map 59 | _Vet.cmd - Examines code and reports suspicious constructs 60 | ``` 61 | 62 | ## Text Files 63 | The batch scripts use the .txt files (Packages.txt and GetPackages.txt) to determine which packages are built and tested. There are two rules when using the .txt files: 64 | * Only one package per line 65 | * Any lines that start with `#` are ignored 66 | 67 | ## How to Use _Get.cmd 68 | To download packages, write each package on a separate line in \workspace\GetPackages.txt and then run _Get.cmd. 69 | 70 | ## Boilerplate Version and Build Date 71 | 72 | One feature I find really useful is the ability to set uninitialized variables at build time using [ldflags](http://stackoverflow.com/questions/11354518/golang-application-auto-build-versioning) for build version and date. 73 | 74 | The BuildDate variable is automatically set in \workspace\\__Global.cmd to: YYYYMMDDHHMMSSMM 75 | 76 | The Version variable is set in: \workspace\BuildVersion.txt 77 | 78 | The LDFLAGS variable is set in \workspace\\__Global.cmd and then used by the scripts: 79 | * _Build.cmd 80 | * _BuildRaceDetector.cmd 81 | * _BuildRun.cmd 82 | * _Install.cmd 83 | 84 | All the boilerplate code is already included in \workspace\src\hello\hello.go. 85 | 86 | ## Boilerplate Tests 87 | 88 | A boilerplate test package is also included at \workspace\src\hello\hello_test.go. 89 | 90 | ## GCC Support 91 | 92 | If you import packages into your workspace that need to be compiled (like github.com/mattn/go-sqlite3), you may receive this error message: 93 | 94 | ``` 95 | exec: "gcc": executable file not found in %PATH% 96 | ``` 97 | 98 | To install gcc and the other executables, I recommend downloading [Win-builds](http://win-builds.org/) and installing the 32-bit version to C:\mingw32 or the 64-bit version to C:\mingw64. Win-builds doesn't actually install, it just extracts the necessary files to those directories so it's nice and clean. LiteIDE and the batch scripts are already configured to use these directories if they exist. 99 | -------------------------------------------------------------------------------- /liteide_config/jrepl.bat: -------------------------------------------------------------------------------- 1 | @if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment 2 | @goto :Batch 3 | 4 | ::JREPL.BAT version 3.4 5 | :: 6 | :: Release History: 7 | :: 2015-01-22 v3.4: Bug fix - Use /TEST instead of TEST as a variable name 8 | :: within the option parser so that it is unlikely to 9 | :: collide with a user defined variable name. 10 | :: 2014-12-24 v3.3: Bug fix for when /JMATCH is combined with /M or /S 11 | :: 2014-12-09 v3.2: Bug fix for /T without /JMATCH - fixed dynamic repl func 12 | :: Added GOTO at top for improved startup performance 13 | :: 2014-11-25 v3.1: Added /JLIB option 14 | :: Exception handler reports when regex is bad 15 | :: Fix /X bug with extended ASCII 16 | :: 2014-11-23 v3.0: Added /JBEGLN and /JENDLN options 17 | :: Added skip, quit, and lpad() global variables/functions 18 | :: Exception handler reports when error in user code 19 | :: 2014-11-21 v2.2: Bug fix for /T with /L option. 20 | :: 2014-11-20 v2.1: Bug fix for /T option when match is an empty string 21 | :: 2014-11-17 v2.0: Added /T (translate) and /C (count input lines) options 22 | :: 2014-11-14 v1.0: Initial release 23 | :: 24 | ::============ Documentation =========== 25 | ::: 26 | :::JREPL Search Replace [/Option [Value]]... 27 | :::JREPL /?[REGEX|REPLACE|VERSION] 28 | ::: 29 | ::: Performs a global regular expression search and replace operation on 30 | ::: each line of input from stdin and prints the result to stdout. 31 | ::: 32 | ::: Each parameter may be optionally enclosed by double quotes. The double 33 | ::: quotes are not considered part of the argument. The quotes are required 34 | ::: if the parameter contains a batch token delimiter like space, tab, comma, 35 | ::: semicolon. The quotes should also be used if the argument contains a 36 | ::: batch special character like &, |, etc. so that the special character 37 | ::: does not need to be escaped with ^. 38 | ::: 39 | ::: Search - By default, this is a case sensitive JScript (ECMA) regular 40 | ::: expression expressed as a string. 41 | ::: 42 | ::: JScript regex syntax documentation is available at 43 | ::: http://msdn.microsoft.com/en-us/library/ae5bf541(v=vs.80).aspx 44 | ::: 45 | ::: Replace - By default, this is the string to be used as a replacement for 46 | ::: each found search expression. Full support is provided for 47 | ::: substituion patterns available to the JScript replace method. 48 | ::: 49 | ::: For example, $& represents the portion of the source that matched 50 | ::: the entire search pattern, $1 represents the first captured 51 | ::: submatch, $2 the second captured submatch, etc. A $ literal 52 | ::: can be escaped as $$. 53 | ::: 54 | ::: An empty replacement string must be represented as "". 55 | ::: 56 | ::: Replace substitution pattern syntax is fully documented at 57 | ::: http://msdn.microsoft.com/en-US/library/efy6s3e6(v=vs.80).aspx 58 | ::: 59 | ::: Options: Behavior may be altered by appending one or more options. 60 | ::: The option names are case insensitive, and may appear in any order 61 | ::: after the Replace argument. 62 | ::: 63 | ::: /A - Only print altered lines. Unaltered lines are discarded. 64 | ::: If the /S option is used, then prints the result only if 65 | ::: there was a change anywhere in the string. The /A option 66 | ::: is incompatible with the /M option unless the /S option 67 | ::: is also present. 68 | ::: 69 | ::: /B - The Search must match the beginning of a line. 70 | ::: Mostly used with literal searches. 71 | ::: 72 | ::: /C - Count the number of input lines and store the result in global 73 | ::: variable cnt. This value can be useful in JScript code associated 74 | ::: with any of the /Jxxx options. 75 | ::: 76 | ::: This option is incompatible with the /M and /S options. 77 | ::: 78 | ::: If the input data is piped or redirected, then the data is first 79 | ::: written to a temporary file, so processing does not start until 80 | ::: the end-of-file is reached. 81 | ::: 82 | ::: /E - The Search must match the end of a line. 83 | ::: Mostly used with literal searches. 84 | ::: 85 | ::: /F InFile 86 | ::: 87 | ::: Input is read from file InFile instead of stdin. 88 | ::: 89 | ::: /I - Makes the search case-insensitive. 90 | ::: 91 | ::: /J - The Replace argument is a JScript expression. 92 | ::: The following variables contain details about each match: 93 | ::: 94 | ::: $0 is the substring that matched the Search 95 | ::: $1 through $n are the captured submatch strings 96 | ::: $off is the offset where the match occurred 97 | ::: $src is the original source string 98 | ::: 99 | ::: /JBEG InitCode 100 | ::: 101 | ::: JScript inititialization code to run prior to loading any input. 102 | ::: This is useful for initializing user defined variables for 103 | ::: accumulating information across matches. The default code is an 104 | ::: empty string. 105 | ::: 106 | ::: /JBEGLN NewLineCode 107 | ::: 108 | ::: JScript code to run at the beginning of each line, prior to 109 | ::: performing any matching on the line. The line content may be 110 | ::: manipulated via the $txt variable. The default code is an empty 111 | ::: string. This option is incompatible with the /M and /S options. 112 | ::: 113 | ::: /JEND FinalCode 114 | ::: 115 | ::: JScript termination code to run when there is no more input to 116 | ::: read. This is useful for writing summarization results. 117 | ::: The default code is an empty string. 118 | ::: 119 | ::: /JENDLN EndLineCode 120 | ::: 121 | ::: JScript code to run at the end of each line, after all matches 122 | ::: on the line have been found, but before the result is printed. 123 | ::: The final result can be modified via the $txt variable. Setting 124 | ::: $txt to false discards the line without printing. The $txt value 125 | ::: is ignored if the /JMATCH option has been used. The default 126 | ::: code is an empty string. This option is incompatible with the 127 | ::: /M and /S options. 128 | ::: 129 | ::: /JLIB FileList 130 | ::: 131 | ::: Specifies one or more files that contain libraries of JScript 132 | ::: code to load before /JBEG is run. Multiple files are delimited 133 | ::: by forward slashes (/). Useful for declaring global variables 134 | ::: and functions in a way that is reusable. 135 | ::: 136 | ::: /JMATCH 137 | ::: 138 | ::: Prints each Replace value on a new line, discarding all text 139 | ::: that does not match the Search. The Replace argument is a 140 | ::: JScript expression with access to the same $ variables available 141 | ::: to the /J option. Replacement values that evaluate to false 142 | ::: are discarded. 143 | ::: 144 | ::: /L - The Search is treated as a string literal instead of a 145 | ::: regular expression. Also, all $ found in the Replace string 146 | ::: are treated as $ literals. 147 | ::: 148 | ::: /M - Multi-line mode. The entire input is read and processed in one 149 | ::: pass instead of line by line, thus enabling search for \n. This 150 | ::: also enables preservation of the original line terminators. 151 | ::: If the /M option is not present, then every printed line is 152 | ::: terminated with carriage return and line feed. The /M option is 153 | ::: incompatible with the /A option unless the /S option is also 154 | ::: present. 155 | ::: 156 | ::: Note: If working with binary data containing NULL bytes, 157 | ::: then the /M option must be used. 158 | ::: 159 | ::: /N MinWidth 160 | ::: 161 | ::: Precede each output line with the line number of the source line, 162 | ::: followed by a colon. Line 1 is the first line of the source. 163 | ::: 164 | ::: The MinWidth value specifies the minimum number of digits to 165 | ::: display. The default value is 0, meaning do not display the 166 | ::: line number. A value of 1 diplays the line numbers without any 167 | ::: zero padding. 168 | ::: 169 | ::: The /N option is ignored if the /M or /S option is used. 170 | ::: 171 | ::: /O OutFile 172 | ::: 173 | ::: Output is written to file OutFile instead of stdout. 174 | ::: 175 | ::: A value of "-" replaces the InFile with the output. The output 176 | ::: is first written to a temporary file with the same name as InFile 177 | ::: with .new appended. Upon completion, the temporary file is moved 178 | ::: to replace the InFile. 179 | ::: 180 | ::: /OFF MinWidth 181 | ::: 182 | ::: Ignored unless the /JMATCH option is used. Precede each output 183 | ::: line with the offset of the match within the original source 184 | ::: string, followed by a colon. Offset 0 is the first character of 185 | ::: the source string. The offset follows the line number if the /N 186 | ::: option is also used. 187 | ::: 188 | ::: The MinWidth value specifies the minimum number of digits to 189 | ::: display. The default value is 0, meaning do not display the 190 | ::: offset. A value of 1 displays the offsets without any zero 191 | ::: padding. 192 | ::: 193 | ::: /S VarName 194 | ::: 195 | ::: The source is read from environment variable VarName instead 196 | ::: of from stdin. Without the /M option, ^ anchors the beginning 197 | ::: of the string, and $ the end of the string. With the /M option, 198 | ::: ^ anchors the beginning of a line, and $ the end of a line. 199 | ::: 200 | ::: The variable name cannot match any of the option names, nor can 201 | ::: it be /TEST. Put another way, any variable can be used as long as 202 | ::: the name does not begin with a forward slash. 203 | ::: 204 | ::: /T DelimiterChar 205 | ::: 206 | ::: The /T option is very similar to the Oracle Translate() function, 207 | ::: or the unix tr command, or the sed y command. 208 | ::: 209 | ::: The Source represents a set of search expressions, and Replace 210 | ::: is a like sized set of replacement expressions. Expressions are 211 | ::: delimited by DelimiterChar (a single character). If DelimiterChar 212 | ::: is an empty string, then each character is treated as its own 213 | ::: expression. The /L option is implicitly set if DelimiterChar is 214 | ::: empty. Escape sequences are interpreted after the search and 215 | ::: replace strings are split into expressions, so escape sequences 216 | ::: cannot be used without a delimiter. 217 | ::: 218 | ::: Each substring from the input that matches a particular search 219 | ::: expression is translated into the corresponding replacement 220 | ::: expression. 221 | ::: 222 | ::: The search expressions may be regular expressions, possibly with 223 | ::: captured subexpression. Note that each expression is itself 224 | ::: converted into a captured subexpression and the operation is 225 | ::: performed as a single search/replace upon execution. So 226 | ::: backreferences within each regex and $n references within each 227 | ::: replacement expression must be adjusted accordingly. 228 | ::: 229 | ::: The total number of expressions plus captured subexpressions must 230 | ::: not exceed 99. 231 | ::: 232 | ::: If an expression must include a delimiter, then an escape 233 | ::: sequence must be used. 234 | ::: 235 | ::: Search expressions are tested from left to right. The left most 236 | ::: matching expression takes precedence when there are multiple 237 | ::: matching expressions. 238 | ::: 239 | ::: /V - Search, Replace, /JBEG InitCode, /JBEGLN NewLineCode, /JEND 240 | ::: FinalCode, and /JENDLN EndLineCode all represent the names 241 | ::: of environment variables that contain the respective values. 242 | ::: An undefined variable is treated as an empty string. 243 | ::: 244 | ::: The variable names must not match any of the option names, nor 245 | ::: can they be /TEST. 246 | ::: 247 | ::: /X - Enables extended substitution pattern syntax with support 248 | ::: for the following escape sequences within the Replace string: 249 | ::: 250 | ::: \\ - Backslash 251 | ::: \b - Backspace 252 | ::: \f - Formfeed 253 | ::: \n - Newline 254 | ::: \q - Quote 255 | ::: \r - Carriage Return 256 | ::: \t - Horizontal Tab 257 | ::: \v - Vertical Tab 258 | ::: \xnn - ASCII byte code expressed as 2 hex digits 259 | ::: \unnnn - Unicode character expressed as 4 hex digits 260 | ::: 261 | ::: Also enables the \q escape sequence for the Search string. 262 | ::: The other escape sequences are already standard for a regular 263 | ::: expression Search string. 264 | ::: 265 | ::: Also modifies the behavior of \xnn in the Search string to work 266 | ::: properly with extended ASCII byte codes (values above 0x7F). 267 | ::: 268 | ::: Extended escape sequences are supported even when the /L option 269 | ::: is used. Both Search and Replace support all of the extended 270 | ::: escape sequences if both the /X and /L opions are combined. 271 | ::: 272 | ::: Extended escape sequences are not applied to JScript code when 273 | ::: using any of the /Jxxx options. Use the decode() function if 274 | ::: extended escape sequences are needed within the code. 275 | ::: 276 | ::: The following global JScript variables/objects/functions are available for 277 | ::: use in JScript code associated with the /Jxxx options. User code may safely 278 | ::: declare additional variables/objects/functions because all other internal 279 | ::: objects used by JREPL are hidden behind an opaque _g object. 280 | ::: 281 | ::: ln - Within /JBEGLN, /JENDLN, and Replace code = current line number 282 | ::: Within /JBEG code = 0 283 | ::: Within /JEND code = total number of lines read. 284 | ::: This value is always 0 if the /M or /S option is used. 285 | ::: 286 | ::: cnt - The total number of lines in the input. The value is undefined 287 | ::: unless the /C option is used. 288 | ::: 289 | ::: skip - If true, do not search/replace any more lines until the value 290 | ::: becomes false. /JBEGLN and /JENDLN code are still executed for 291 | ::: each line, regardless. If set to true while in the midst of 292 | ::: searching a line, then that search will continue to the end of 293 | ::: the current line. 294 | ::: 295 | ::: The default value is false. 296 | ::: 297 | ::: This variable has no impact if the /M or /S options is used. 298 | ::: 299 | ::: quit - If true, then do not read any more lines of input. The current 300 | ::: line is still processed to completion, and /JEND code is still 301 | ::: executed afterward. 302 | ::: 303 | ::: The default value is false. 304 | ::: 305 | ::: This variable has no impact if the /M or /S options is used. 306 | ::: 307 | ::: env('varName') 308 | ::: 309 | ::: Access to environment variable named varName. 310 | ::: 311 | ::: decode(string) 312 | ::: 313 | ::: Decodes extended escape sequences within a string as defined 314 | ::: by the /X option, and returns the result. All backslashes must 315 | ::: be escaped an extra time to use this function in your code. 316 | ::: 317 | ::: Examples: 318 | ::: quote literal: decode('\\q') 319 | ::: extended ASCII(128): decode('\\x80') 320 | ::: backslash literal: decode('\\\\') 321 | ::: 322 | ::: This function is only needed if you use the \q sequence 323 | ::: or \xnn for an extended ASCII code (values above 0x7F). 324 | ::: 325 | ::: lpad(value,pad) 326 | ::: 327 | ::: Used to left pad a value to a minimum width string. If the 328 | ::: value already has string width >= the pad length, then no 329 | ::: change is made. Otherwise it left pads the value with the 330 | ::: characters of the pad string to the width of the pad string. 331 | ::: 332 | ::: Examples: 333 | ::: lpad(15,'0000') returns "0015" 334 | ::: lpad(15,' ') returns " 15" 335 | ::: lpad(19011,'0000') returns "19011" 336 | ::: 337 | ::: input - The TextStream object from which input is read. 338 | ::: This may be stdin or a file. 339 | ::: 340 | ::: output - The TextStream object to which the output is written. 341 | ::: This may be stdout or a file. 342 | ::: 343 | ::: stdin - Equivalent to WScript.StdIn 344 | ::: 345 | ::: stdout - Equivalent to WScript.StdOut 346 | ::: 347 | ::: stderr - Equivalent to WScript.StdErr 348 | ::: 349 | ::: Help is available by supplying a single argument beginning with /?: 350 | ::: 351 | ::: /? - Writes this help documentation to stdout. 352 | ::: 353 | ::: /?REGEX - Opens up Microsoft's JScript regular expression 354 | ::: documentation within your browser. 355 | ::: 356 | ::: /?REPLACE - Opens up Microsoft's JScript REPLACE documentation 357 | ::: within your browser. 358 | ::: 359 | ::: /?VERSION - Writes the JREPL version number to stdout. 360 | ::: 361 | ::: Return Codes: 362 | ::: 363 | ::: 0 = At least one change was made and /JMATCH not used 364 | ::: or at least one match returned and /JMATCH was used 365 | ::: or /? was used 366 | ::: 367 | ::: 1 = No change was made and /JMATCH not used 368 | ::: or no match returned and /JMATCH was used 369 | ::: 370 | ::: 2 = Invalid call syntax or incompatible options 371 | ::: 372 | ::: 3 = JScript runtime error 373 | ::: 374 | ::: JREPL.BAT was written by Dave Benham, and originally posted at 375 | ::: http://www.dostips.com/forum/viewtopic.php?f=3&t=6044 376 | ::: 377 | 378 | ============= :Batch portion =========== 379 | @echo off 380 | setlocal disableDelayedExpansion 381 | 382 | if .%2 equ . ( 383 | if "%~1" equ "/?" ( 384 | for /f "tokens=* delims=:" %%A in ('findstr "^:::" "%~f0"') do @echo(%%A 385 | exit /b 0 386 | ) else if /i "%~1" equ "/?regex" ( 387 | explorer "http://msdn.microsoft.com/en-us/library/ae5bf541(v=vs.80).aspx" 388 | exit /b 0 389 | ) else if /i "%~1" equ "/?replace" ( 390 | explorer "http://msdn.microsoft.com/en-US/library/efy6s3e6(v=vs.80).aspx" 391 | exit /b 0 392 | ) else if /i "%~1" equ "/?version" ( 393 | for /f "tokens=* delims=:" %%A in ('findstr "^::JREPL\.BAT" "%~f0"') do @echo(%%A 394 | exit /b 0 395 | ) else ( 396 | call :err "Insufficient arguments" 397 | exit /b 2 398 | ) 399 | ) 400 | 401 | :: Define options 402 | set "options= /A: /B: /C: /E: /F:"" /I: /J: /JBEG:"" /JBEGLN:"" /JEND:"" /JENDLN:"" /JLIB:"" /JMATCH: /L: /M: /N:0 /O:"" /OFF:0 /S:"" /T:"none" /V: /X: " 403 | 404 | :: Set default option values 405 | for %%O in (%options%) do for /f "tokens=1,* delims=:" %%A in ("%%O") do set "%%A=%%~B" 406 | 407 | :: Get options 408 | :loop 409 | if not "%~3"=="" ( 410 | set "/test=%~3" 411 | setlocal enableDelayedExpansion 412 | if "!/test:~0,1!" neq "/" ( 413 | call :err "Too many arguments" 414 | exit /b 2 415 | ) 416 | set "/test=!options:*%~3:=! " 417 | if "!/test!"=="!options! " ( 418 | endlocal 419 | call :err "Invalid option %~3" 420 | exit /b 2 421 | ) else if "!/test:~0,1!"==" " ( 422 | endlocal 423 | set "%~3=1" 424 | ) else ( 425 | endlocal 426 | set "%~3=%~4" 427 | shift /3 428 | ) 429 | shift /3 430 | goto :loop 431 | ) 432 | 433 | :: Validate options 434 | if defined /M if defined /A if not defined /S ( 435 | call :err "/M cannot be used with /A without /S" 436 | exit /b 2 437 | ) 438 | if "%/O%" equ "-" if not defined /F ( 439 | call :err "Output = - but Input file not specified" 440 | exit /b 2 441 | ) 442 | if defined /F if defined /O for %%A in ("%/F%") do for %%B in ("%/O%") do if %%~fA equ %%~fB ( 443 | call :err "Output file cannot match Input file" 444 | exit /b 2 445 | ) 446 | if "%/C%%/JBEGLN%%/JENDLN%" neq "" if "%/M%%/S%" neq "" ( 447 | call :err "/JBEGLN and /JENDLN cannot be used with /M or /S" 448 | exit /b 2 449 | ) 450 | 451 | :: Transform options 452 | if defined /JMATCH set "/J=1" 453 | if "%/M%%/S%" neq "" set "/N=0" 454 | 455 | :: Execute 456 | cscript //E:JScript //nologo "%~f0" %1 %2 457 | exit /b %errorlevel% 458 | 459 | :err 460 | >&2 ( 461 | echo ERROR: %~1. 462 | echo (Use JREPL /? to get help.^) 463 | ) 464 | exit /b 465 | 466 | ************* JScript portion **********/ 467 | var _g=new Object(); 468 | _g.loc=''; 469 | try { 470 | var env=WScript.CreateObject("WScript.Shell").Environment("Process"), 471 | cnt, 472 | ln=0, 473 | skip=false, 474 | quit=false, 475 | stdin=WScript.StdIn, 476 | stdout=WScript.Stdout, 477 | stderr=WScript.Stderr, 478 | output, 479 | input; 480 | _g.ForReading=1; 481 | _g.ForWriting=2; 482 | _g.TemporaryFolder=2; 483 | _g.fso = new ActiveXObject("Scripting.FileSystemObject"); 484 | _g.inFile=env('/F'); 485 | _g.outFile=env('/O'); 486 | _g.tempFile=''; 487 | if (_g.inFile=='') { 488 | if (env('/C')) { 489 | _g.tempFile=_g.fso.GetSpecialFolder(_g.TemporaryFolder).path+'\\'+_g.fso.GetTempName(); 490 | _g.inFile=_g.tempFile; 491 | input=stdin; 492 | output=_g.fso.OpenTextFile(_g.tempFile,_g.ForWriting,true); 493 | while (!stdin.AtEndOfStream) output.WriteLine(input.ReadLine()); 494 | cnt=input.line-1; 495 | output.close(); 496 | input=_g.fso.OpenTextFile(_g.tempFile,_g.ForReading); 497 | } else input=stdin; 498 | } else { 499 | if (env('/C')) { 500 | input=_g.fso.OpenTextFile(_g.inFile,_g.ForReading); 501 | while (!input.AtEndOfStream) input.SkipLine(); 502 | cnt=input.line-1; 503 | input.close(); 504 | } 505 | input=_g.fso.OpenTextFile(_g.inFile,_g.ForReading); 506 | } 507 | if (_g.outFile=='') { 508 | output=stdout 509 | } else if (_g.outFile=='-') { 510 | output=_g.fso.OpenTextFile(_g.inFile+'.new',_g.ForWriting,true); 511 | } else { 512 | output=_g.fso.OpenTextFile(_g.outFile,_g.ForWriting,true); 513 | } 514 | if (env('/JLIB')) { 515 | _g.loc=' while loading /JLIB code'; 516 | var libs=env('/JLIB').split('/'); 517 | for (var i=0; i0?Array(lnWidth+1).join('0'):'', 582 | offPad=offWidth>0?Array(offWidth+1).join('0'):'', 583 | xcnt=0, test; 584 | if (translate=='none') { // Normal 585 | if (env('/X')) { 586 | if (!jexpr) replace=decode(replace); 587 | search=decode(search,literal); 588 | } 589 | if (literal) { 590 | search=search.replace(/([.^$*+?()[{\\|])/g,"\\$1"); 591 | if (!jexpr) replace=replace.replace(/\$/g,"$$$$"); 592 | } 593 | if (env('/B')) search="^"+search; 594 | if (env('/E')) search=search+"$"; 595 | _g.loc=' in Search regular expression'; 596 | search=new RegExp(search,options); 597 | _g.log=''; 598 | if (jexpr) { 599 | _g.loc=' in Search regular expression'; 600 | test=new RegExp('.|'+search,options); 601 | _g.loc=''; 602 | 'x'.replace(test,function(){xcnt=arguments.length-2; return '';}); 603 | _g.replFunc='_g.replFunc=function($0'; 604 | for (var i=1; i1) throw new Error(203, 'Invalid /T delimiter'); 611 | search=search.split(translate); 612 | if (search.length>99) throw new Error(202, '/T expression count exceeds 99'); 613 | var replace=replace.split(translate); 614 | if (search.length!=replace.length) throw new Error(201, 'Mismatched search and replace /T expressions'); 615 | _g.replace=[]; 616 | var j=1; 617 | for (var i=0; i99) throw new Error(202, '/T expressions + captured expressions exceeds 99'); 628 | if (env('/B')) search[i]="^"+search[i]; 629 | if (env('/E')) search[i]=search[i]+"$"; 630 | if (jexpr) { 631 | _g.replace[j]=replace[i]; 632 | } else { 633 | replace[i]="'" + (env('/X')==''?replace[i]:decode(replace[i])).replace(/[\\']/g,"\\$&") + "'"; 634 | replace[i]=replace[i].replace(/\n/g, "\\n"); 635 | replace[i]=replace[i].replace(/\r/g, "\\r"); 636 | if (!literal) { 637 | _g.replace[j]=replace[i].replace( 638 | /\$([$&`]|\\'|(\d)(\d)?)/g, 639 | function($0,$1,$2){ 640 | return ($1=="$")?"$": 641 | ($1=="&")?"'+$0+'": 642 | ($1=="`")?"'+$src.substr(0,$off)+'": 643 | ($1=="\\'")?"'+$src.substr($off+$0.length)+'": 644 | (Number($1)-j<=xcnt && Number($1)>j)?"'+"+$0+"+'": 645 | (Number($2)-j<=xcnt && Number($1)>j)?"'+"+$0+"+'"+$3: 646 | $0; 647 | } 648 | ); 649 | } else _g.replace[j]=replace[i]; 650 | } 651 | j+=xcnt+1; 652 | } 653 | search='('+search.join(')|(')+')'; 654 | _g.loc=' in Search regular expression'; 655 | search=new RegExp( search, options ); 656 | _g.loc=''; 657 | _g.replFunc='_g.replFunc=function($0'; 658 | for (var i=1; i