Replace utils.Once with stdlib sync.OnceValue

This commit is contained in:
Kovid Goyal
2023-08-09 12:08:42 +05:30
parent 49ea26968c
commit 4f72bb9894
22 changed files with 53 additions and 96 deletions

View File

@@ -9,6 +9,7 @@ import (
"io"
"os"
"strconv"
"sync"
"time"
"golang.org/x/sys/unix"
@@ -340,7 +341,7 @@ func (self *Term) GetSize() (*unix.Winsize, error) {
// go doesn't have a wrapper for ctermid()
func Ctermid() string { return "/dev/tty" }
var KittyStdout = utils.Once(func() *os.File {
var KittyStdout = sync.OnceValue(func() *os.File {
if fds := os.Getenv(`KITTY_STDIO_FORWARDED`); fds != "" {
if fd, err := strconv.Atoi(fds); err == nil && fd > -1 {
if f := os.NewFile(uintptr(fd), "<kitty_stdout>"); f != nil {