Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"time"
"github.com/seiyab/akashi"
)
type User struct {
ID string
Name string
RegisteredAt time.Time
}
func main() {
s := akashi.DiffString(
User{
ID: "123",
Name: "Alice",
RegisteredAt: time.Date(2025, 2, 3, 23, 3, 15, 0, time.UTC),
},
User{
ID: "123",
Name: "Alice",
RegisteredAt: time.Date(2024, 12, 19, 5, 45, 50, 0, jst),
},
)
fmt.Println(s)
}
Output: akashi_test.User{ ID: "123", Name: "Alice", - RegisteredAt: time.Time("2025-02-03 23:03:15 +0000 UTC"), + RegisteredAt: time.Time("2024-12-19 05:45:50 +0900 JST"), }
Example (Slice) ¶
package main
import (
"fmt"
"github.com/seiyab/akashi"
)
func main() {
s := akashi.DiffString(
[]string{"a", "b", "c", "d"},
[]string{"a", "c", "d", "e"},
)
fmt.Println(s)
}
Output: []string{ "a", - "b", "c", "d", + "e", }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultColorProfile = ColorProfile{
Left: "\x1b[31m",
Right: "\x1b[32m",
Neutral: "",
Reset: "\x1b[0m",
}
Functions ¶
func DiffString ¶
DiffString returns a string that represents the difference between x and y.
Types ¶
type ColorProfile ¶ added in v0.0.3
type ColorProfile = doc.ColorProfile
type Option ¶
type Option func(*differ) *differ
Option is an option for DiffString.
func WithColor ¶ added in v0.0.3
func WithColor(profile ...ColorProfile) Option
func WithFormat ¶
func WithFormat(fn interface{}) Option
WithFormat sets a function to format a value.
Example ¶
package main
import (
"fmt"
"time"
"github.com/seiyab/akashi"
)
func main() {
s := akashi.DiffString(
time.Date(2025, 2, 3, 23, 3, 15, 0, time.UTC),
time.Date(2024, 12, 19, 5, 45, 50, 0, time.UTC),
akashi.WithFormat(
func(t time.Time) string {
return t.Format(time.RFC3339)
},
),
)
fmt.Println(s)
}
Output: - time.Time("2025-02-03T23:03:15Z") + time.Time("2024-12-19T05:45:50Z")
Source Files
¶
Click to show internal directories.
Click to hide internal directories.