Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
lamarmarshall / deleteElslice.go
Created October 26, 2017 00:39
go delete element from slice
delete := func(a []int, index int) []int {
last := index + 1
a = append(a[:index], a[last:]...)
return a
}
fmt.Println("deleted ", delete(sls, 2))
@lamarmarshall
lamarmarshall / multislice.go
Created October 26, 2017 03:18
go multislice array
package main
import (
"fmt"
)
func main() {
records := make([][]string, 3)
record := make([]string, 4)
record[0] = "lamar"
package main
import (
"fmt"
)
func main() {
var input string
fmt.Print("what is your name: ")
fmt.Scanln(&input)
@lamarmarshall
lamarmarshall / slicecopy.go
Created October 26, 2017 05:22
go copy slice vale transfer
package main
import (
"fmt"
)
func main() {
grades := []float32{2.5, 3.0, 1.5, 3.5, 4.0, 2.5}
minig := make([]float32, 4)
@lamarmarshall
lamarmarshall / mapcheck.go
Created October 26, 2017 05:43
check hashmap, delete hashmap
package main
import (
"fmt"
)
func main() {
x := map[string]string{
"lamar": "king",
"bob": "pee-on",
@lamarmarshall
lamarmarshall / panictest.go
Created October 26, 2017 06:07
go paniic recover
package main
import (
"fmt"
)
func main() {
fmt.Println("program started to run")
testpanic()
fmt.Println("program ended")
@lamarmarshall
lamarmarshall / tokenizer.go
Created October 26, 2017 18:14
go string tokenizer
package main
import (
"fmt"
"strings"
)
func main() {
str := "the big dog has very lazy friends"
@lamarmarshall
lamarmarshall / fileplay.js
Created October 26, 2017 20:12
nodejs file append get logged in user info
console.log("starting app")
const fs = require('fs')
const os = require('os')
var user = os.userInfo();
@lamarmarshall
lamarmarshall / chanstream.go
Last active October 26, 2017 21:57
go chan concurrent stream threads
package main
import (
"fmt"
"time"
)
func main(){
stream := make( chan int)
go sendStream(stream)
@lamarmarshall
lamarmarshall / threadtest.go
Created October 26, 2017 21:58
go thread concurrency
package main
import (
"fmt"
)
func main() {
ch := make(chan bool)
go sayChan(ch)