wip: migrate to mono-repo. SPN has already been moved to spn/

This commit is contained in:
Patrick Pacher
2024-03-15 11:55:13 +01:00
parent b30fd00ccf
commit 8579430db9
577 changed files with 35981 additions and 818 deletions

27
spn/terminal/fmt.go Normal file
View File

@@ -0,0 +1,27 @@
package terminal
import "fmt"
// CustomTerminalIDFormatting defines an interface for terminal to define their custom ID format.
type CustomTerminalIDFormatting interface {
CustomIDFormat() string
}
// FmtID formats the terminal ID together with the parent's ID.
func (t *TerminalBase) FmtID() string {
if t.ext != nil {
if customFormatting, ok := t.ext.(CustomTerminalIDFormatting); ok {
return customFormatting.CustomIDFormat()
}
}
return fmtTerminalID(t.parentID, t.id)
}
func fmtTerminalID(craneID string, terminalID uint32) string {
return fmt.Sprintf("%s#%d", craneID, terminalID)
}
func fmtOperationID(craneID string, terminalID, operationID uint32) string {
return fmt.Sprintf("%s#%d>%d", craneID, terminalID, operationID)
}