v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-16 15:50:52 -07:00
GTT/utils.go
2022-10-23 11:38:12 +08:00

37 lines
499 B
Go

package main
func IndexOf(candidate string, arr []string) int {
for index, element := range arr {
if element == candidate {
return index
}
}
return -1
}
func SetTermTitle(title string) {
print("\033]0;", title, "\007")
}
type Lock struct {
stop bool
threadCount int8
}
func NewLock() *Lock {
return &Lock{
stop: true,
threadCount: 0,
}
}
func (l *Lock) Aquire() {
l.stop = false
l.threadCount++
}
func (l *Lock) Release() {
l.stop = true
l.threadCount--
}