MCPcopy Create free account
hub / github.com/SamNet-dev/snix / randomUUID

Function randomUUID

cmd/snix/wizard.go:298–311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

296}
297
298func randomUUID() string {
299 var b [16]byte
300 if _, err := rand.Read(b[:]); err != nil {
301 // crypto/rand on Linux reads from getrandom()/urandom; on Windows
302 // from CryptGenRandom. Only way this fails is catastrophic OS
303 // breakage. Panic loudly so the user doesn't ship an all-zero UUID.
304 panic("crypto/rand failed: " + err.Error())
305 }
306 // v4 format
307 b[6] = (b[6] & 0x0f) | 0x40
308 b[8] = (b[8] & 0x3f) | 0x80
309 s := hex.EncodeToString(b[:])
310 return s[0:8] + "-" + s[8:12] + "-" + s[12:16] + "-" + s[16:20] + "-" + s[20:]
311}
312
313func writeConfigYAML(path string, cfg *config.Config) error {
314 if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {

Callers 1

runWizardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected