GithubHelp home page GithubHelp logo

rickar / props Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 4.0 42 KB

Go (golang) library for Java-style property files

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%
go golang java-properties

props's Introduction

props: Go (golang) library for handling Java-style property files and app configuration

This library provides compatibility with Java property files for Go.

It also provides additional features such as property expansion, configuration by convention, and encryption for use as application configuration. The approach is similar to that of the Environment classes of Spring Boot.

Important Types

There are three main types provided:

  • Properties - read and write property files in Java format
  • Expander - replaces property references wrapped by '${}' (or other custom prefix/suffix) at runtime (as found in Ant/Log4J/JSP EL/Spring)
  • Configuration - provides easy configuration by convention, parsing of property values into Go types, and encryption support

The full Java property file format including all comment types, line continuations, key-value separators, unicode escapes, etc. is supported.

Configuration by Convention

The standard convention supported provides for profile and environment specific property files along with command line arguments and environment variables.

Properties are resolved in the following priority order:

  1. Command line arguments
  2. Environment variables
  3. <prefix>-<profile>.properties for the provided prefix and profiles values (in order)
  4. <prefix>.properties for the provided prefix value

The first matching property value found will be returned.

Custom Configuration

The types provided can be included or excluded in any order to create an alternative configuration.

  • Arguments
  • Environment
  • Expander
  • Properties

Combine multiple property source lookups with the Combined type.

Command Line Utility

A command line utility is provided in the cmd directory. This app is used to encrypt, decrypt, or re-encrypt property files or individual values.

Encryption

Encryption is handled by putting a marker prefix ([enc:x]) on encrypted values. The prefix indicates which algorithm was used for encryption and allows for different algorithms to co-exist or be upgraded at different times in the same file.

The standard approach is to update your property file with plaintext values with the [enc:0] prefix, for example:

db.password=[enc:0]$ecr3t!

Then run the encryptFile command from app in the cmd dir to convert the result into an encrypted value:

db.password=[enc:1]<base64 data>

props's People

Contributors

rickar avatar rothskeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.