scc2go

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MPL-2.0 Imports: 8 Imported by: 1

README

SCC to Go Viper

Go Reference Go CI/CD codecov Go Report Card Latest Release

License

FOSSA Status

Package Go untuk mengambil konfigurasi aplikasi dari Spring Cloud Config Server dan langsung menyimpannya ke Viper untuk kemudahan akses di aplikasi Go.

✨ Fitur

  • Fetch konfigurasi langsung dari Spring Cloud Config Server (/application/profile)
  • Support authentication (username/password)
  • Integrasi otomatis dengan Viper
  • Mendukung format konfigurasi: YAML, JSON, Properties (auto mapping ke Viper)
  • Cocok untuk aplikasi Go yang ingin pakai central config seperti Spring di ekosistem Java

🚀 Instalasi

go get -u github.com/KAnggara75/scc2go

🔧 Penggunaan

1. Import package
import (
	"github.com/KAnggara75/scc2go"
)
2. Inisialisasi dan ambil konfigurasi
func init() {
	scc2go.GetEnv(os.Getenv("SCC_URL"), os.Getenv("AUTH"))
}
3. Akses konfigurasi di Viper
package config

import (
	"github.com/spf13/viper"
)

func GetDBConn() string {
	return viper.GetString("db.myapp.host")
}
4. Contoh penggunaan
package main
import (
    "fmt"
    "os"

    "github.com/KAnggara75/scc2go"
    "github.com/spf13/viper"
)

func init() {
	scc2go.GetEnv(os.Getenv("SCC_URL"), os.Getenv("AUTH"))
}

func main() {
	deviceId := viper.GetString("db.myapp.host")
	fmt.Println("Device ID:", deviceId)
}

📝 Konfigurasi yang Didukung

  • Format: .yaml, .yml, .json, .properties
  • Key mapping otomatis dari response Spring Cloud Config ke viper

🔒 Autentikasi

  • Tambahkan field Auth jika server butuh basic auth.
scc2go.GetEnv("SCC_URL", "AUTH")

📦 Versioning

This project follows Semantic Versioning with automated releases based on Conventional Commits.

For detailed information about versioning and commit message format, see VERSIONING.md.

Quick Reference
  • feat: - New feature (minor version bump)
  • fix: - Bug fix (patch version bump)
  • feat!: or BREAKING CHANGE: - Breaking change (major version bump)

🧪 Testing

Run tests with coverage:

go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Current test coverage: 97.1%

🤝 Kontribusi

Pull request & masukan sangat diterima!

How to Contribute
  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes using Conventional Commits
    • feat: add new feature
    • fix: resolve bug
    • docs: update documentation
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

See VERSIONING.md for commit message guidelines.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(sccUrl, auth string, disableTlsOpt ...bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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