5449 explained code solutions for 103 technologies

golangHow to check if file not exist

package main

import (

func main() {
  if _, err := os.Stat("/no/such/file"); errors.Is(err, os.ErrNotExist) {
    fmt.Println("no such file")
}ctrl + c
package main

default package declaration


include operating-system level library

func main() {

declare main function that will be launched automatically


retrieve file stats


check if raised error is of specified type


raises when there are no such file