parent
fd2e59f47a
commit
c14e0dfcab
|
@ -1,2 +1,5 @@
|
|||
# Build output
|
||||
*.test
|
||||
|
||||
# Emacs
|
||||
*~
|
||||
|
|
|
@ -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:
|
||||
|
|
5
Makefile
5
Makefile
|
@ -1,7 +1,10 @@
|
|||
all: test
|
||||
|
||||
test:
|
||||
test: linter
|
||||
go test
|
||||
|
||||
linter:
|
||||
golangci-lint run
|
||||
|
||||
goimports_everything:
|
||||
find . -name "*.go" -exec goimports -w {} \;
|
||||
|
|
29
Readme.md
29
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.
|
||||
|
|
Loading…
Reference in New Issue