Giter Site home page Giter Site logo

textfiletogoconst's Introduction

textFileToGoConst

GoDoc WTFPL License GoReportCard

Go generate tool to put a text file to string constant of your Go project.

Go 1.6+

Please refer to go:embed first. This package is not needed anymore.

Installation

Get

go get -u github.com/logrusorgru/textFileToGoConst

The go get command installs textFileToGoConst executable in your $GOPATH/bin or $GOBIN/ directory.

The project comes without any tests.

Usage

For example, if you want to use Redis with your Go application and want to use Lua scripts. Since, it is easy to use separate *.lua files to use syntax highlighting and other editing features. But it's not easy to load this files at runtime, or if you want content of the files to be a constant of you Go project. And since, manual copy-pasting is hard and slow. Thus, the textFileToGoConst puts content of text file to you Go project, creating *.go file with.

For example, the following file

package some

//go:generate textFileToGoConst -in get.lua
//go:generate textFileToGoConst -in getIncr.lua
//go:generate textFileToGoConst -in getNotTouch.lua
//go:generate textFileToGoConst -in getIncrNotTouch.lua

used to generate Go files

  • get.lua.go
  • getIncr.lua.go
  • getNotTouch.lua.go
  • getIncrNotTouch.lua.go

with something like this

package some

const getLua = `<content of the get.lua file>`

Flags and arguments

  • in - source file name (required)
  • o - output file name (defaults to source + .go)
  • p - package name (defaults to autodetect)
  • c - constant name (defaults to CamelCased file name without dots)
  • h - show help

And trailing argument, that describes destination folder, folder with Go project (defaults to .)

Contributing

Feel free.

Licensing

Copyright © 2018 Konstantin Ivanov [email protected]
This work is free. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the LICENSE file for more details.

textfiletogoconst's People

Contributors

dmitris avatar logrusorgru avatar

Stargazers

 avatar

Watchers

 avatar  avatar

textfiletogoconst's Issues

Option to suppress generation date in the output

We'd like to introduce a validation step in our CI to ensure that all generated files were committed. The idea is to run go generate and check git status afterwards. Since textFileToGoConst puts the generation date in the output, we see changes every time.

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.