September 2017
Intermediate to advanced
466 pages
9h 33m
English
Symbolic links are pointers to files or directories, which are resolved at the time of access. Symbolic links, which are also called soft links, are not equal to the file or the directory they are pointing to and are allowed to point to nowhere, which can sometimes complicate things.
The following Go code, saved in symbLink.go and presented in two parts, allows you to check whether a path or file is a symbolic link or not. The first part is as follows:
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide an argument!")
os.Exit(1)
}
filename := arguments[1]
Nothing special is happening here: you just need to make sure that you get one ...
Read now
Unlock full access