https://github.com/r2dtools/goapacheconf
GoApacheConf is a Go library for parsing, modifying, and regenerating Apache configuration files. It makes it easy to work with Apache config blocks and directives programmatically in your Go applications.
https://github.com/r2dtools/goapacheconf
apache config configuration developer-tools devops golang parser
Last synced: 23 days ago
JSON representation
GoApacheConf is a Go library for parsing, modifying, and regenerating Apache configuration files. It makes it easy to work with Apache config blocks and directives programmatically in your Go applications.
- Host: GitHub
- URL: https://github.com/r2dtools/goapacheconf
- Owner: r2dtools
- License: mit
- Created: 2025-08-17T14:35:49.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-16T11:53:44.000Z (5 months ago)
- Last Synced: 2025-12-18T08:05:12.277Z (4 months ago)
- Topics: apache, config, configuration, developer-tools, devops, golang, parser
- Language: Go
- Homepage:
- Size: 469 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoApacheConf
**GoApacheConf** is a Go library for parsing, modifying, and regenerating **Apache configuration files**.
It makes it easy to work with Apache config blocks and directives programmatically in your Go applications.
Powered by [Participle v2](https://github.com/alecthomas/participle) under the hood.
---
## 📦 Installation
```bash
go get github.com/r2dtools/goapacheconf
```
---
## 🚀 Usage Example
Parse the entire Apache configuration and inspect blocks and directives:
```go
package main
import (
"fmt"
"github.com/r2dtools/goapacheconf"
)
func main() {
// Load Apache config from /etc/apache2
config, err := goapacheconf.GetConfig("/etc/apache2", "")
if err != nil {
panic(err)
}
// Find VirtualHost blocks
blocks := config.FindVirtualHostBlocks()
if len(blocks) == 0 {
panic("virtual host block not found")
}
vBlock := blocks[0]
// Get DocumentRoot
fmt.Println(vBlock.GetDocumentRoot())
// Find "ErrorLog" directives
directives := vBlock.FindDirectives("ErrorLog")
if len(directives) == 0 {
panic("directive not found")
}
// Print the first ErrorLog directive value
fmt.Println(directives[0].GetFirstValue())
}
```
👉 For more examples, check the tests.
---
## 🔧 Roadmap
- Support for additional Apache directive types
- Advanced helpers for config manipulation
- Built-in config validation
---
## 📜 License
MIT License. See [LICENSE](./LICENSE) for details.