This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //slices.Equal(slice1, slice2) | |
| a := [5]int{1, 2, 3, 4, 5} | |
| slices1 := a[1:4] // from index 1 to index 3 | |
| sliceCopy := make([]int, len(slices1)) | |
| if slices.Equal(slices1, sliceCopy) { | |
| fmt.Println("slices1 and sliceCopy are equal") | |
| } else { | |
| fmt.Println("slices1 and sliceCopy are not equal") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // []T{e1, e2, e3, ...} | |
| // Where T is the type of the elements (e.g., int, string, bool, struct), | |
| // and e1, e2, e3, etc., are the initial elements of the slice | |
| fruits := []string{"Apple", "Banana", "Orange"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fruits := [4]string{"Apple", "Banana", "Orange", "Grapes"} | |
| for index, fruit := range fruits { | |
| fmt.Println(position, fruitName) | |
| } | |
| for i, v := range fruits { | |
| fmt.Println(i, v) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| fruits := [4]string{"Apple", "Banana", "Orange", "Grapes"} | |
| fmt.Println("Fruits array:", fruits) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| realpath file.txt | |
| # realpath is part of GNU coreutils | |
| # Installed by default on most Linux distributions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo $SHELL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dnf install nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dnf upgrade or dnf update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat /etc/passwd |
NewerOlder