Go - Functions - 2


  • Modifications to the parameter copy don't affect the caller except pointer, slice, map, function, channel
  • A function declaration without a body indicate that the function is implemented in a language other than Go
  • A function can have multiple return values, client can assign return value to a blank identifier to ignore
    • Ex. data, _ = findData()
  • Function can be assigned to variable
  • Ex. func a(){}; func b(){}; f=a; f(); f+b; f()
    Ex. func d(s string) {}; f=d; // compile error
  • Zero value of function is nil
  • Can use == to compare function (can only check is function nil), but function is not comparable so can not be key in map

沒有留言:

張貼留言

Lessons Learned While Benchmarking vLLM with GPU

Recently, I benchmarked vLLM on a GPU to better understand how much throughput can realistically be expected in an LLM serving setup. One ...