util

package
v0.0.0-...-a06519d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util contians various helping functions for jdkenv (i.e. downloading and extracting compressed tarballs).

Copyright © 2020 Nathan Adams <aurumcodex@protonmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// ErrNone is the error code that means that nothing bad happened when executing.
	ErrNone int = 0
	// ErrVer is an error code for an invalid JDK/Java version passed into program.
	ErrVer int = 1
	// ErrConf is an error code for a configuration file not found.
	ErrConf int = 2
	// ErrDL is an error code for a downloading failure.
	ErrDL int = 3
	// ErrExtr is an error code for an extraction failure.
	ErrExtr int = 4

	// ErrArch is an error code for incompatible CPU architecture.
	// * Currently unused
	ErrArch int = 124
	// ErrOS is an error code for incompatible OS.
	ErrOS int = 125
)
View Source
const (
	// Corretto flag for setting/using Corretto as JDK of choice.
	Corretto int = iota

	// Liberica flag for setting/using Liberica as JDK of choice.
	Liberica int = iota

	// OpenJDK flag for setting/using OpenJDK as JDK of choice.
	OpenJDK int = iota

	// OpenJ9 flag for setting/using OpenJdk with OpenJ9 JVM as JDK of choice.
	OpenJ9 int = iota

	// Oracle flag for setting/using Oracle as JDK of choice.
	Oracle int = iota

	// Azul flag for setting/using Azul Zulu as JDK of choice.
	Azul int = iota

	// Sapmachine flag for setting/using Sapmachine as JDK of choice.
	Sapmachine int = iota
)
View Source
const (
	JavaHomePath string = `export PATH="${JAVA_HOME}/bin:${PATH}`

	Corretto8Home  string = `export JAVA_HOME="${HOME}/.jdkenv/amazon-corretto-8"`
	Corretto11Home string = `export JAVA_HOME="${HOME}/.jdkenv/amazon-corretto-11"`

	Liberica8Home  string = `export JAVA_HOME="${HOME}/.jdkenv/bellsoft-liberica-8"`
	Liberica11Home string = `export JAVA_HOME="${HOME}/.jdkenv/bellsoft-liberica-11"`
	Liberica15Home string = `export JAVA_HOME="${HOME}/.jdkenv/bellsoft-liberica-15"`

	Oracle8Home  string = `export JAVA_HOME="${HOME}/.jdkenv/oracle-openjdk-8"`
	Oracle11Home string = `export JAVA_HOME="${HOME}/.jdkenv/oracle-openjdk-11"`
	Oracle15Home string = `export JAVA_HOME="${HOME}/.jdkenv/oracle-openjdk-15"`

	OpenJDK8Home  string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-8"`
	OpenJDK11Home string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-11"`
	OpenJDK14Home string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-14"`
	OpenJDK15Home string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-15"`

	OpenJ98Home  string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-openj9-8"`
	OpenJ911Home string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-openj9-11"`
	OpenJ914Home string = `export JAVA_HOME="${HOME}/.jdkenv/adoptopenjdk-openj9-14"`
)

Constants for determining what to put into the `.env` file in `~/.jdkenv` and also the filenames to download to.

Variables

This section is empty.

Functions

func BuildString

func BuildString(inputs ...string) string

BuildString collects inputs passed to it and concatenates them into one larger string. Used for building URLs for use in downloading JDKs and other files

func CheckRuntime

func CheckRuntime()

CheckRuntime is a wrapper to check if the environment is Windows or not. Used since Windows is not currently supported at this time.

func CheckValidJDK

func CheckValidJDK(jdk, version int) bool

CheckValidJDK checks the given integer(s) and returns `true` if valid JDK is available, otherwise returns `false`.

func Download

func Download(jdk, version int, url, dest string, spinner bool, aur aurora.Aurora) error

Download gets a file from a given string and stores it.

func Extract

func Extract(path, dest string, spinner, color bool, aur aurora.Aurora) error

Extract wraps `archiver.Unarchive()` for simplicity, with added spinner effect. Takes path parameter and extracts to dest parameter.

func JDKType

func JDKType(jdk, version int) string

JDKType returns a string for the Download function to print which JDK and version is being downloaded.

func PrintErrorList

func PrintErrorList()

PrintErrorList prints out a list of all error codes that can be generated when running the program.

func SetCorretto

func SetCorretto(dest string, version int, spin, color bool, aur aurora.Aurora) (error, error, error)

SetCorretto sets the Java environment to use the Amazon Corretto JDK.

func SetLiberica

func SetLiberica(dest string, version int, spin, color bool, aur aurora.Aurora) (error, error, error)

SetLiberica sets the Java environment to use the BellSoft Liberica JDK.

func SetOpenJDK

func SetOpenJDK(dest string, version int, openj9, spin, color bool, aur aurora.Aurora) (error, error, error)

SetOpenJDK sets the Java environment to use an AdoptOpenJDK implementation.

func SetOracle

func SetOracle(dest string, version int, spin, color bool, aur aurora.Aurora) (error, error, error)

SetOracle sets the Java environment to use a reference implementation of OpenJDK built by Oracle.

func WriteEnvFile

func WriteEnvFile(jdk, version int)

WriteEnvFile writes to the `.env` file found within the `~/.jdkenv` directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL