diff --git a/.gitignore b/.gitignore index b8372e6..a62efc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +# Build output +*.test + # Emacs *~ diff --git a/License.md b/License.md index 42670c5..453e5da 100644 --- a/License.md +++ b/License.md @@ -1,7 +1,6 @@ # BSD 2-Clause License Copyright (c) 2022, Sean Hickey (Wisellama) -All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/Makefile b/Makefile index 07c6d98..b9d53b9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ all: test -test: +test: linter go test +linter: + golangci-lint run + goimports_everything: find . -name "*.go" -exec goimports -w {} \; diff --git a/Readme.md b/Readme.md index 44cd3ec..7c07d96 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,7 @@ # gosimpleconf ```sh -go get gitea.wisellama.rocks/Wisellama/gosimpleconf@v0.0.1 +go get gitea.wisellama.rocks/Wisellama/gosimpleconf@v0.0.2 ``` This is a small library for parsing super simple configuration files. @@ -17,6 +17,28 @@ map for you to do whatever your program wants with them. If you need a value to not be a string, you will have to convert the value from a string as needed for your program (e.g. using the `strconv` library). +## Example + +Here's an example config file `file.conf` +```conf +url = www.wisellama.rocks +number_of_widgets = 1337 +pi = 3.141592653589793238462643383 +environment = production +``` + +Then to load that config file into a map: + +```go +configMap, err := gosimpleconf.Load("file.conf") +``` + +Then everything is a string. You can parse it as needed. +```go +var piStr string = configMap["pi"] +pi, err := strconv.ParseFloat(value, 64) +``` + ## Why? I've always seen configuration files similar to this show up in @@ -37,3 +59,8 @@ it unless Go fundamentally breaks the language in the future. So while the project may eventually look like it has been abandoned, it is rather simply "complete". (*gasp* I know, such a rare thing in the software world). + +## License + +This project is licensed under the 2-Clause BSD License (a permissive +open source license). See `License.md` for the full text. diff --git a/simpleconf.go b/gosimpleconf.go similarity index 100% rename from simpleconf.go rename to gosimpleconf.go diff --git a/simpleconf_test.go b/gosimpleconf_test.go similarity index 100% rename from simpleconf_test.go rename to gosimpleconf_test.go