dogfootman.com

  • 홈
  • 태그
  • 방명록

struct 2

[Go] 구조체를 여러가지 방법으로 깊은 복사 하는 방법 + 성능비교 (How to deep copy a struct in various ways + Performance comparison)

개요구조체를 여러가지 방법으로 깊은 복사각 복사 방법의 성능 비교 (Benchmark)벤치마크 참고: https://dogfootman.com/14 [Go] Benchmark 사용법 (How to Use Benchmarks)개요Benchmark의 사용법   1. 기본 사용법func BenchmarkXxx(*testing.B) 의 형태를 가지고 있으면 벤치마크로 간주되며-bench 의 플러그가 있으면 go test 의 명령에 의해서 실행된다  샘플코드package main...fdogfootman.com  1. 수동으로 깊은 복사package mainimport "fmt"type Address struct { City string State string}type Student struct { ..

[Go] 2024.06.25

[Go] 제네릭 사용 예 (Example of using generics)

개요go 1.18에서 추가 된 제네릭의 사용 예   1. 함수에서의 사용package mainimport "fmt"func Filter[T any](list []T, predicate func(T) bool) []T { var result []T for _, v := range list { if predicate(v) { result = append(result, v) } } return result}func main() { // 짝수만 필터 nums := []int{1, 2, 3, 4, 5, 6} evens := Filter(nums, func(n int) bool { return n%2 == 0 }) fmt.Println(evens) // [2 4 6] // 길이가 5가 넘는 문자열만 필터..

[Go] 2024.06.23
이전
1
다음
더보기
  • View All Categories (13)
    • [Unity] (3)
      • [Unity 2D] (3)
    • [Go] (9)
    • [ETC] (1)

Tag

scroll wheel, deep copy, Dependency, Golang, pre-request script, Unity, Slice, go, gob, API, benchmark, cycle not allowed, 고랭, Interface, mouse position, Unity 2D, Performance, Camera, test, struct,

최근글과 인기글

  • 최근글
  • 인기글

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바