SkillAgentSearch skills...

Gotemplate4j

Go template implementation in Java

Install / Use

/learn @verils/Gotemplate4j
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Golang Template Engine for Java

Testing

Evaluate go templates and make textual output.

Before then, there is another fine library with a name not so intuitive: Java Template Engine, you can choose that if you like.

This project is for experimental purpose, please DON'T USE IN PRODUCTION for now because the support for complex number and builtin functions is incomplete. Wish I can finish them ASAP.

You can see the changelog to know what's happening.

Requirements

Java Version: >= 1.8

No other dependency required except for Vanilla Java

Installation

For Maven, you can simply add dependency:

<dependency>
    <groupId>io.github.verils</groupId>
    <artifactId>gotemplate4j</artifactId>
    <version>0.3.1</version>
</dependency>

Usage

// Create a user as the input data
User user = new User();
user.setName("Bob");

// Prepare you template
Template template = new Template("demo");
template.parse("Hello, {{ .Name }}!");

// Execute and print out the result text
StringWriter writer = new StringWriter();
template.execute(writer, user);
System.out.print(writer.toString());  // "Hello Bob!"

Limitations

  • The format of print functions in Java are different from Golang
  • Achieved only a few built-in functions
  • The procedure of PipeNode is weak

Waht is Next?

  • [x] Support complex number format
  • [ ] Support all built-in functions in Golang
  • [ ] Complete PipeNode for all types of identifiers
View on GitHub
GitHub Stars15
CategoryDevelopment
Updated10mo ago
Forks3

Languages

Java

Security Score

87/100

Audited on May 18, 2025

No findings