Skip to content

Example application "Hello World" with the mvn-golang-wrapper plugin

License

Notifications You must be signed in to change notification settings

raydac/mvn-golang-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example how to build a GoLang application with Maven and the mvn-golang-wrapper plugin.
Just clone the project and build with mvn package

What is Maven?

Maven is very popular tool in Java world allows to build projects and the main power of maven in its central repository which allows to load dependencies without tricks.
If you have not maven installed on your computer, you can visit its home page and read instructions how to install. Also the project contains mvnw wrapper which can download maven automatically.

Build and start

To get compiled example Golang application you should make listed steps:

  • (optional step) download and install JDK
  • just clone the repository with git clone https://github.com/raydac/mvn-golang-example.git
  • go to the cloned project folder
  • build the project with mvn command if you have installed maven or with maven wrapper mvnw which will download maven automatically
  • go to the generated bin folder and execute result file named binResult

Screencast

Screencast

Create from archetype

It is possible to create "Hello World" project just from maven archetype

mvn archetype:generate -B -DarchetypeGroupId=com.igormaznitsa -DarchetypeArtifactId=mvn-golang-hello -DarchetypeVersion=2.3.9 -DgroupId=com.go.test -DartifactId=gohello -Dversion=1.0-SNAPSHOT

if you want to develop multi-module project sharing some sources, you can use muti-module archetype

mvn archetype:generate -B -DarchetypeGroupId=com.igormaznitsa -DarchetypeArtifactId=mvn-golang-hello-multi -DarchetypeVersion=2.3.9 -DgroupId=com.go.test -DartifactId=gohello-multi -Dversion=1.0-SNAPSHOT

What to do if I want to use pre-installed Golang SDK?

In the case just define <goRoot> in plug-in configuration

<goRoot>some/folder/where/go</goRoot>

and plug-in will be using already installed distributive

I want to export already presented environment variables $GOROOT and $GOPATH

By defaut the plug-in using only parameters defined in its configuration, if you want to enable import of environment parameters $GOROOT, $GOOS, $GOARCH and $GOROOT_BOOTSTRAP (if they defined), then just add flag <useEnvVars>into plug-in configuration

<useEnvVars>true</useEnvVars>

About

Example application "Hello World" with the mvn-golang-wrapper plugin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages