분류 전체보기
-
TypeScript 제네릭 패턴과 활용법 - 클래스, 함수, 메서드 완벽 분석Javascript 2024. 5. 15. 21:31
제네릭이란?언제 유용할까?배열에서 다루는 타입을 지정하고 싶을 때함수나 메서드의 인수에 범용성을 부여하고 싶을 때보충 설명: 인수의 수가 다른 오버로드제네릭을 클래스 타입으로기본응용: 여러 개의 타입 인수 지정타입 인수 기본값 설정타입 인수에 제약을 두기제네릭 메서드 제네릭이란?Java에서는 제네릭스(Generics)라고 불리기도 합니다. 언어마다 이 용어의 표현이 다르죠. TypeScript에서도 제네릭스나 제너릭스라고 불리기도 합니다. 제네릭은 "총칭형(総称型)"이라고도 불리며, 임의의 클래스나 메서드에 대해 임의의 타입을 연결할 수 있는 구조입니다. 자세한 내용은 여기와 여기에서 확인할 수 있습니다.언제 유용할까?배열에서 다루는 타입을 지정하고 싶을 때예를 들어 배열 변수를 정의할 때, 이 배열이..
-
TypeScript 4.5 이상 버전에서 추가된 TSConfig 옵션 살펴보기Javascript 2024. 5. 12. 07:17
tsconfig.json에는 많은 옵션이 존재합니다. 최근 2년 동안 TSConfig에 새롭게 어떤 옵션들이 추가되었는지 궁금해졌습니다. TypeScript 4.5의 릴리스가 2021년 11월 즈음이었으므로 약 2년 전이니, TypeScript 4.5 이후에 추가된 TSConfig 옵션들을 조사해보았습니다.버전 4.5 이후 새로 추가된 옵션 목록옵션추가된 버전preserveValueImports4.5moduleSuffixes4.7moduleDetection4.7allowArbitraryExtensions5.0allowImportingTsExtensions5.0customConditions5.0resolvePackageJsonExports5.0resolvePackageJsonImports5.0verbati..
-
TypeScript를 다른 도구로 다루기 위한 컴파일러 옵션Javascript 2024. 5. 11. 21:27
** 목차 **TypeScript를 다른 도구로 다루기 위한 컴파일러 옵션isolatedModulesisolatedModules가 해결하는 문제isolatedModules의 동작 예시에러 해결 방법verbatimModuleSyntaxverbatimModuleSyntax의 의의isolatedDeclarations의 아이디어isolatedDeclarations에 따른 제약 사항마무리TypeScript 프로젝트에서는 빌드 속도가 중요합니다. TypeScript의 빌드 속도는 CI/CD의 효율성과 직결되기 때문입니다. 하지만 tsc가 그렇게 빠르지 않다는 것은 잘 알려진 사실이며, tsc 외에 다른 도구를 TypeScript 빌드 파이프라인에 섞어 쓰는 것도 자주 있습니다. TypeScript(tsc) 컴파일러..
-
json.Unmarshal 사용시 타임(time) 형식을 유연하게 변경하는 방법Go 2024. 5. 4. 17:41
Go 언어에서 json.Unmarshal을 사용하여 JSON 데이터를 구조체로 변환할 때, 시간 필드의 형식을 유연하게 지정할 수 있는 방법이 있는데요. 사용자 정의 시간 필드 타입을 만들거나, 라이브러리를 사용하여 기본적인 time.Time 타입 대신 다른 형식의 시간 문자열을 처리할 수 있다는 겁니다. 예를 들어, tson 라이브러리는 사용자가 시간 형식을 설정할 수 있게 해주며, 이 설정을 통해 json.Unmarshal을 사용할 때 해당 형식을 사용할 수 있는겁니다. ** 목차 **json.Unmarshal 사용시 타임(time) 형식을 유연하게 변경하는 방법앞으로 사용할 구조체와 변수tson 라이브러리 사용시좀 더 생각해 보기해결책상세 구현마무리앞으로 사용할 구조체와 변수이 글에서 사용할 구조체..
-
JSON-LD로 구조화된 데이터를 Next.js 사이트에 추가하여 SEO 개선하기Javascript 2024. 5. 3. 19:41
** 목 차 **JSON-LD로 구조화된 데이터를 Next.js 사이트에 추가하여 SEO 개선하기SEO의 중요성JSON-LD란?구조화된 데이터란?구조화된 데이터의 유형Next.js 사이트에 JSON-LD 구조화된 데이터 추가하기SEO의 중요성많은 개발자들이 자신의 블로그 글이나 유투브 동영상에 SEO를 전혀 고려치 않고 있는데요. 그런데, 사실 SEO에 대해 조금만 배우면 상당히 도움이 됩니다. Google, DuckDuckGo, Bing 같은 검색엔진이 여러분의 사이트가 무엇에 관한 것이며, 어떤 분야에서 전문성이 있는지 알 수 있도록 사이트를 구성하는 것이 트래픽을 늘릴 수 있게 도움을 주는데요. 오늘 알아볼 글에서 구조화된 데이터와 JSON-LD에 관한 정보를 알아보고, Next.js를 위한 코드 ..
-
Go 언어 인터페이스 구현 패턴Go 2024. 4. 14. 11:58
안녕하세요? 오늘은 Go 언어 인터페이스 구현 패턴과 함께 type, 메소드 그리고 인터페이스의 기본적인 설명을 추가하여 아래와 같은 것들을 살펴볼 예정입니다.Go 언어에서의 인터페이스 부분 구현 패턴struct에 interface를 포함시켜 동적으로 교체하는 패턴먼저 type과 메소드, 기본적인 인터페이스 구현 방법에 대해 잠시나마 복습해보겠습니다. ** 목 차 **Go 언어 인터페이스 구현 패턴type으로 타입을 선언하기메소드기본적인 인터페이스의 구현함수에 인터페이스 구현하기구조체에 포함시켜 인터페이스 구현하기인터페이스의 부분 구현을 위한 임베딩 사용인터페이스의 동적 구현을 위한 임베딩 사용마지막으로type으로 타입을 선언하기우선, Go 언어에서의 타입 선언 방법입니다. Go 언어를 처음 시작하는 분..
-
Go의 채널 처리 패턴 모음Go 2024. 4. 13. 12:19
안녕하세요? 오늘은 Go의 채널 처리 패턴에 대해 알아보겠습니다. ** 목 차 **Go의 채널 처리 패턴 모음Go의 채널 기초정의close송신수신주의해야 할 사항일반적인 안티패턴종료를 수신자에게 알리기 위해 종료 이벤트를 보내기close될 가능성이 있는 채널을 첫 번째 반환값으로만 받기goroutine에서 여러 이벤트가 올 수 있는데 처음 것만 받고 빠져나가기채널이 닫혔는지 확인하고 싶은 경우고속으로 보내기채널로 병렬 수 관리하는 경우의 패턴채널로 처리 종료를 기다리는 패턴채널의 close를 감지하는 패턴채널에서 반복 처리하는 경우의 패턴 모음송신 측 1개, 수신 측 1개송신 측 1개, 수신 측 다수송신 측 다수, 수신 측 1개송신 측 다수, 수신 측 다수select 대기에 대해에러 수집(하나만 잡으면 ..
-
도커 튜토리얼 2부: Go로 만든 REST API를 Dockerfile 이용해서 도커에 넣기Docker 2024. 3. 31. 17:28
안녕하세요? 도커 튜토리얼 시리즈 2번째입니다. 오늘은 1편에서 배운 도커 기초를 바탕으로 Dockerfile에 대해 살펴보겠습니다. Dockerfile은 도커 이미지를 쉽게 만들어 주는 파일인데요. 오늘은 Go 언어로 작성한 REST API를 Dockerfile을 이용해서 도커에 넣어 실행시켜 보겠습니다.** 목 차 **도커 튜토리얼 2부: Go로 만든 REST API Dockerfile 이용해서 도커에 넣기Go REST API 작성하기Dockerfile 이란?dockerignore 파일도커 이미지 만들기도커 이미지 실행하기Dockerfile에 실행 코드까지 넣기DockerHub에 이미지 올려보기Go REST API 작성하기테스트를 위해 먼저 Go 언어로 REST API를 만들어야겠죠. 가장 기본적인 ..