• Stars
    star
    605
  • Rank 74,072 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Package goconfig is a fully functional and comments-support configuration file (.ini) parser.

goconfig Go Walker

中文文档

IMPORTANT

  • This library is under bug fix only mode, which means no more features will be added.
  • I'm continuing working on better Go code with a different library: ini.

About

Package goconfig is a easy-use, comments-support configuration file parser for the Go Programming Language, which provides a structure similar to what you would find on Microsoft Windows INI files.

The configuration file consists of sections, led by a [section] header and followed by name:value or name=value entries. Note that leading whitespace is removed from values. The optional values can contain format strings which refer to other values in the same section, or values in a special DEFAULT section. Comments are indicated by ";" or "#"; comments may begin anywhere on a single line.

Features

  • It simplified operation processes, easy to use and undersatnd; therefore, there are less chances to have errors.
  • It uses exactly the same way to access a configuration file as you use Windows APIs, so you don't need to change your code style.
  • It supports read recursion sections.
  • It supports auto increment of key.
  • It supports READ and WRITE configuration file with comments each section or key which all the other parsers don't support!!!!!!!
  • It supports get value through type bool, float64, int, int64 and string, methods that start with "Must" means ignore errors and get zero-value if error occurs, or you can specify a default value.
  • It's able to load multiple files to overwrite key values.

Installation

go get github.com/unknwon/goconfig

API Documentation

Go Walker.

Example

Please see conf.ini as an example.

Usage

  • Function LoadConfigFile load file(s) depends on your situation, and return a variable with type ConfigFile.
  • GetValue gives basic functionality of getting a value of given section and key.
  • Methods like Bool, Int, Int64 return corresponding type of values.
  • Methods start with Must return corresponding type of values and returns zero-value of given type if something goes wrong.
  • SetValue sets value to given section and key, and inserts somewhere if it does not exist.
  • DeleteKey deletes by given section and key.
  • Finally, SaveConfigFile saves your configuration to local file system.
  • Use method Reload in case someone else modified your file(s).
  • Methods contains Comment help you manipulate comments.
  • LoadFromReader allows loading data without an intermediate file.
  • SaveConfigData added, which writes configuration to an arbitrary writer.
  • ReloadData allows to reload data from memory.

Note that you cannot mix in-memory configuration with on-disk configuration.

More Information

  • All characters are CASE SENSITIVE, BE CAREFUL!

Credits

License

This project is under Apache v2 License. See the LICENSE file for the full license text.

More Repositories

1

the-way-to-go_ZH_CN

《The Way to Go》中文译本,中文正式名《Go 入门指南》
Go
34,552
star
2

go-fundamental-programming

《Go 编程基础》是一套针对 Google 出品的 Go 语言的视频语音教程,主要面向新手级别的学习者。
Go
9,024
star
3

go-study-index

Go 语言学习资料索引
6,447
star
4

go-web-foundation

《Go Web 基础》是一套针对 Google 出品的 Go 语言的视频语音教程,主要面向完成《Go 编程基础》教程后希望进一步了解有关 Go Web 开发的学习者。
Go
2,670
star
5

go-rock-libraries-showcases

《Go名库讲解》是一套针对 Google 出品的 Go 语言的第三方库进行评测讲解的集博客、示例与语音视频为一体的综合教程,适合完成学习完成《Go编程基础》教程的学习者。
Go
1,604
star
6

com

This is an open source project for commonly used functions for the Go programming language.
Go
757
star
7

gowalker

Go Walker is a server that generates Go projects API documentation on the fly.
Go
660
star
8

building-web-applications-in-go

Go 语言 Web 应用开发系列教程,从新手到双手残废
Go
577
star
9

bra

Bra (Brilliant Ridiculous Assistant) is a command line utility tool.
Go
399
star
10

go-code-convention

@unknwon's opinionated and paranoid Go code convention.
348
star
11

gcblog

An open source project for Golang China blog.
Go
103
star
12

i18n

Package i18n is for app Internationalization and Localization.
Go
84
star
13

qiniudrive

七牛云盘是基于七牛开放 API 构建的第三方同步程序
C#
70
star
14

paginater

Package paginater is a helper module for custom pagination calculation.
Go
48
star
15

flamego-basics

《Flamego 框架基础》是一套针对 Go 语言 Web 框架 Flamego 出品的视频语音教程,主要面向 Web 应用开发者
Go
47
star
16

cae

Package cae implements PHP-like Compression and Archive Extensions.
Go
36
star
17

go-import-server

HTTP server for canonical "go get" import path
Go
33
star
18

wam

wam(Weibo Automated Management) - Golang中国微博自动化管理程序
Go
23
star
19

orbiter

Orbiter is a tool for collecting and redistributing webhooks over the network.
Go
20
star
20

leetcode.go

My Golang solutions to https://leetcode.com/
Go
19
star
21

CharmControlLibrary

C# GDI+ 实现的伪子类化控件类库
C#
17
star
22

labeler

Labeler is a CLI tool to sync labels for a GitHub repository with templates.
Go
13
star
23

figo

Fig(http://fig.sh) in Go.
Go
11
star
24

log

Package log is a dead simple, levelable, colorful logging library.
Go
10
star
25

docker-sync-to-aliyun

Sync Docker images to Aliyun's registry
8
star
26

gopha

gopha is a package for implementation of Perceptual Hash Algorithm in Go programming language.
Go
8
star
27

sublite

SubLite is a theme converter from Sublime Text to LiteIDE.
Go
7
star
28

unknwon

Go
5
star
29

rods

The collection of RODs written by @unknwon for researching and describing engineering efforts.
5
star
30

Project-Spartan

The Project Spartan is a hybrid-infrastructure and research-oriented HA (High Availability) prototype for IT 485.
JavaScript
4
star
31

fws

Fibonacci Web Server
Go
2
star
32

unknwon.cn

SCSS
1
star
33

sublime-sourcegraph-theme

Sourcegraph Color Scheme for SublimeText 3.
1
star
34

buildkite-flaky-reporter

HTTP server for reporting flaky tests and cancellation on Buildkite
Go
1
star