Coder Social home page Coder Social logo

my-go-playground's Introduction

๐Ÿฆซ my Go playground

My Go playground while learning Go. ๐Ÿง‘โ€๐Ÿš’
so be cautious that the codes is not sophisticated and may not follow the best practice.

Run playground simply by go test: ๐Ÿš€

go test ./...

๐Ÿ› Playground List

  • nil_empty_playground.go | nil_empty_playground_test.go
    • check the behavior of nil/empty slice
    • check the behavior of nil/empty map
      • put new elements into nil map, PANIC!
    • check the behavior of nil function/lambda
      • call nil function/lambda, PANIC!
  • string_playground.go | string_playground_test.go
    • check the difference between len and rune count of string
    • conversion of
      • string <=> []rune
      • rune => string
      • string <=> []byte
      • byte => string
      • []rune <=> []byte
    • string iteration
      • for-range loop iteration return RUNE value with BYTE index, NOT return byte value,
        make mistakes very easily, need caution!
      • iterate with byte index only of string by for-range loop, lose bytes! NONSENSE!!
    • check memory struct of string by SizeOf
  • goroutine_channel_playground.go | goroutine_channel_playground_test.go
    • read channel by for-range loop, very convenient
    • read channel by comma-ok pattern, more tedious but safe too
  • goroutine_channel_pattern_playground.go | goroutine_channel_pattern_playground_test.go
    • operation(read/write) to multiply channels with select statement avoid starvation/deadlock
    • done channel pattern aka. a channel only used to publish close event
    • cancel function pattern to terminate a goroutine
    • nilify the case channel pattern to turning off a case in a select
    • time after case pattern to time out code
  • when_go_runtime_panic_playground.go | when_go_runtime_panic_playground_test.go
    • array operation panic
    • slice operation panic
    • channel operation panic
    • function value operation, call nil function value panic
    • call value receiver method with nil point receiver panic
    • call method of nil interface panic
    • call method of interface with nil value panic
    • pointer operation, dereference a nil pointer panic
    • type assertions panic

๐Ÿ˜ˆ My common functions and go design experiments

  • commons.go
    • in my personal opinion,
      type voidT = struct{} and var void = voidT{}
      definitions seems interesting and COOL

my-go-playground's People

Contributors

oldratlee avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.