Help us shape the future of Go! Take the 2026 Go Developer Survey

hini4g

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2024 License: Apache-2.0

README

hini4g

hooto INI file read library for golang.

Example:

package main

import (
	"fmt"

	"github.com/hooto/hini4g/hini"
)

func main() {

	ini_str := `
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/hooto/hini4g.git
	fetch = +refs/heads/*:refs/remotes/origin/*
`

	options, err := hini.ParseString(ini_str)
	if err == nil {
		fmt.Println("remote/origin/url : ", options.Value("remote/origin/url").String())

		if _, ok := options.ValueOK("core/filemode"); ok {
			fmt.Println("core/filemode : exist")
		}

		if _, ok := options.ValueOK("remote/none/url"); !ok {
			fmt.Println("remote/none/url : not exist")
		}
	}

	options, err = hini.ParseFile("/path/to/file.ini")
	if err == nil {
		fmt.Println("remote/origin/url : ", options.Value("remote/origin/url").String())
	}
}

Output:

remote/origin/url :  https://github.com/hooto/hini4g.git
core/filemode : exist
remote/none/url : not exist

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL