diff --git a/404.html b/404.html index f690689..2aa8544 100644 --- a/404.html +++ b/404.html @@ -9,13 +9,13 @@ - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/241a966b.62f942f6.js b/assets/js/241a966b.62f942f6.js new file mode 100644 index 0000000..6f4e1fa --- /dev/null +++ b/assets/js/241a966b.62f942f6.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkfoomo=self.webpackChunkfoomo||[]).push([[5719],{3905:(r,e,t)=>{t.d(e,{Zo:()=>p,kt:()=>g});var n=t(7294);function o(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function a(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var e=1;e=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}var c=n.createContext({}),l=function(r){var e=n.useContext(c),t=e;return r&&(t="function"==typeof r?r(e):s(s({},e),r)),t},p=function(r){var e=l(r.components);return n.createElement(c.Provider,{value:e},r.children)},u="mdxType",d={inlineCode:"code",wrapper:function(r){var e=r.children;return n.createElement(n.Fragment,{},e)}},m=n.forwardRef((function(r,e){var t=r.components,o=r.mdxType,a=r.originalType,c=r.parentName,p=i(r,["components","mdxType","originalType","parentName"]),u=l(t),m=o,g=u["".concat(c,".").concat(m)]||u[m]||d[m]||a;return t?n.createElement(g,s(s({ref:e},p),{},{components:t})):n.createElement(g,s({ref:e},p))}));function g(r,e){var t=arguments,o=e&&e.mdxType;if("string"==typeof r||o){var a=t.length,s=new Array(a);s[0]=m;var i={};for(var c in e)hasOwnProperty.call(e,c)&&(i[c]=e[c]);i.originalType=r,i[u]="string"==typeof r?r:o,s[1]=i;for(var l=2;l{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>s,default:()=>d,frontMatter:()=>a,metadata:()=>i,toc:()=>l});var n=t(7462),o=(t(7294),t(3905));const a={},s="Errors",i={unversionedId:"projects/gotsrpc/service-interfaces/errors",id:"projects/gotsrpc/service-interfaces/errors",title:"Errors",description:"Handling errors is always hard and you have to differentiate about some capabilites between server-to-server and server-to-frontend communications:",source:"@site/docs/projects/gotsrpc/service-interfaces/errors.md",sourceDirName:"projects/gotsrpc/service-interfaces",slug:"/projects/gotsrpc/service-interfaces/errors",permalink:"/docs/projects/gotsrpc/service-interfaces/errors",draft:!1,editUrl:"https://github.com/foomo/foomo-docs/tree/main/foomo/docs/projects/gotsrpc/service-interfaces/errors.md",tags:[],version:"current",frontMatter:{},sidebar:"projectsSidebar",previous:{title:"Value Objects",permalink:"/docs/projects/gotsrpc/service-interfaces/value-objects"},next:{title:"TypeScript client transport",permalink:"/docs/projects/gotsrpc/client-transport"}},c={},l=[{value:"Server to Server",id:"server-to-server",level:2},{value:"Server to Frontend",id:"server-to-frontend",level:2},{value:"String Error Types",id:"string-error-types",level:3},{value:"Struct Error Types",id:"struct-error-types",level:3}],p={toc:l},u="wrapper";function d(r){let{components:e,...t}=r;return(0,o.kt)(u,(0,n.Z)({},p,t,{components:e,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"errors"},"Errors"),(0,o.kt)("p",null,"Handling errors is always hard and you have to differentiate about some capabilites between server-to-server and server-to-frontend communications:"),(0,o.kt)("h2",{id:"server-to-server"},"Server to Server"),(0,o.kt)("p",null,"When using server to server communication you can use the regular go ",(0,o.kt)("inlineCode",{parentName:"p"},"error")," interface.\nSince interfaces are not typed but still need to be able to checked on the client side, gotsrpc will wrap them during the encode phase to keep the information using ",(0,o.kt)("inlineCode",{parentName:"p"},"mapstructure"),"."),(0,o.kt)("p",null,"NOTE: Be aware though, that private attributes on structs will be lost during transportation"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go"},'type CustomError struct {\n Message string\n data string // will be lost\n}\n\nfunc (e *CustomError) Error() string {\n return e.Message\n}\n\ntype Service interface {\n Do() (err error)\n}\n\nfunc main() {\n // ...\n err, clientErr := client.Do()\n if clientErr != nil {\n panic("client error") \n }\n \n // you will be able to use errors.Is() or errors.As()\n var customErr *CustomError\n if errors.As(err, &customErr) {\n // ... \n }\n if errors.Is(err, os.ErrExist) {\n // ...\n }\n}\n')),(0,o.kt)("h2",{id:"server-to-frontend"},"Server to Frontend"),(0,o.kt)("p",null,"On the frontend side, everything needs to be strictly typed so sth like this, does not transport well, since an interface implementation can not be marshalled."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go"},"// from https://go.dev/blog/error-handling-and-go\ntype error interface {\n Error() string\n}\n")),(0,o.kt)("h3",{id:"string-error-types"},"String Error Types"),(0,o.kt)("p",null,"Scalar string error types provide a nice way to combine Go constants, that translate to TypeScript enums as errors:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type ScalarError string\n\nconst (\n ErrorFoo ScalarError = "foo"\n ErrorBar ScalarError = "bar"\n)\n\nfunc (e *ScalarError) Error() string {\n return string(*e)\n}\n\ntype Service interface {\n MightGoWrong() *ScalarError\n}\n')),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},'export enum ScalarError {\n ErrorBar = "bar",\n ErrorFoo = "foo",\n}\n\nexport interface ServiceClient {\n mightGoWrong(): Promise;\n}\n')),(0,o.kt)("h3",{id:"struct-error-types"},"Struct Error Types"),(0,o.kt)("p",null,"If an enumeration is not enough and you want to add information to your errors a struct is a good choice (be careful not to expose secrets \ud83d\ude09) :"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"it can still implement the Error type"),(0,o.kt)("li",{parentName:"ul"},"it is still typed in contrast to other alternatives like maps")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type ErrorCode int\n\nconst (\n ErrorCodeFoo ErrorCode = 1\n ErrorCodeBar ErrorCode = 2\n)\n\ntype StructError struct {\n Message string `json:"message,omitempty"`\n Code ErrorCode `json:"errorCode"`\n}\n\nfunc (e *StructError) Error() string {\n return e.Message\n}\n\ntype Service struct {\n MightGoWrong() *StructError\n}\n')),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"export enum ErrorCode {\n Bar = 2,\n Foo = 1,\n}\n\nexport interface StructError {\n message?:string;\n errorCode:ErrorCode;\n}\n\nexport interface ServiceClient {\n mightGoWrong(): Promise;\n}\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/241a966b.90b4b489.js b/assets/js/241a966b.90b4b489.js deleted file mode 100644 index 6f06c43..0000000 --- a/assets/js/241a966b.90b4b489.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkfoomo=self.webpackChunkfoomo||[]).push([[5719],{3905:(r,e,t)=>{t.d(e,{Zo:()=>l,kt:()=>f});var n=t(7294);function o(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function a(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var e=1;e=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}var i=n.createContext({}),p=function(r){var e=n.useContext(i),t=e;return r&&(t="function"==typeof r?r(e):s(s({},e),r)),t},l=function(r){var e=p(r.components);return n.createElement(i.Provider,{value:e},r.children)},u="mdxType",m={inlineCode:"code",wrapper:function(r){var e=r.children;return n.createElement(n.Fragment,{},e)}},g=n.forwardRef((function(r,e){var t=r.components,o=r.mdxType,a=r.originalType,i=r.parentName,l=c(r,["components","mdxType","originalType","parentName"]),u=p(t),g=o,f=u["".concat(i,".").concat(g)]||u[g]||m[g]||a;return t?n.createElement(f,s(s({ref:e},l),{},{components:t})):n.createElement(f,s({ref:e},l))}));function f(r,e){var t=arguments,o=e&&e.mdxType;if("string"==typeof r||o){var a=t.length,s=new Array(a);s[0]=g;var c={};for(var i in e)hasOwnProperty.call(e,i)&&(c[i]=e[i]);c.originalType=r,c[u]="string"==typeof r?r:o,s[1]=c;for(var p=2;p{t.r(e),t.d(e,{assets:()=>i,contentTitle:()=>s,default:()=>m,frontMatter:()=>a,metadata:()=>c,toc:()=>p});var n=t(7462),o=(t(7294),t(3905));const a={},s="Errors",c={unversionedId:"projects/gotsrpc/service-interfaces/errors",id:"projects/gotsrpc/service-interfaces/errors",title:"Errors",description:"On the Go server side errors are types, that implement the error type:",source:"@site/docs/projects/gotsrpc/service-interfaces/errors.md",sourceDirName:"projects/gotsrpc/service-interfaces",slug:"/projects/gotsrpc/service-interfaces/errors",permalink:"/docs/projects/gotsrpc/service-interfaces/errors",draft:!1,editUrl:"https://github.com/foomo/foomo-docs/tree/main/foomo/docs/projects/gotsrpc/service-interfaces/errors.md",tags:[],version:"current",frontMatter:{},sidebar:"projectsSidebar",previous:{title:"Value Objects",permalink:"/docs/projects/gotsrpc/service-interfaces/value-objects"},next:{title:"TypeScript client transport",permalink:"/docs/projects/gotsrpc/client-transport"}},i={},p=[{value:"String Error Types",id:"string-error-types",level:2},{value:"Struct Error Types",id:"struct-error-types",level:2}],l={toc:p},u="wrapper";function m(r){let{components:e,...t}=r;return(0,o.kt)(u,(0,n.Z)({},l,t,{components:e,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"errors"},"Errors"),(0,o.kt)("p",null,"On the Go server side errors are types, that implement the error type:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go"},"// from https://go.dev/blog/error-handling-and-go\ntype error interface {\n Error() string\n}\n")),(0,o.kt)("p",null,"This does not transport well, since an interface implementation can not be marshalled."),(0,o.kt)("h2",{id:"string-error-types"},"String Error Types"),(0,o.kt)("p",null,"Scalar string error types provide a nice way to combine Go constants, that translate to TypeScript enums as errors:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type ScalarError string\n\nconst (\n ErrorFoo ScalarError = "foo"\n ErrorBar ScalarError = "bar"\n)\n\nfunc (e *ScalarError) Error() string {\n return string(*e)\n}\n\ntype Service interface {\n MightGoWrong() *ScalarError\n}\n')),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},'export enum ScalarError {\n ErrorBar = "bar",\n ErrorFoo = "foo",\n}\n\nexport interface ServiceClient {\n mightGoWrong(): Promise;\n}\n')),(0,o.kt)("h2",{id:"struct-error-types"},"Struct Error Types"),(0,o.kt)("p",null,"If an enumeration is not enough and you want to add information to your errors a struct is a good choice (be careful not to expose secrets \ud83d\ude09) :"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"it can still implement the Error type"),(0,o.kt)("li",{parentName:"ul"},"it is still typed in contrast to other alternatives like maps")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type ErrorCode int\n\nconst (\n ErrorCodeFoo ErrorCode = 1\n ErrorCodeBar ErrorCode = 2\n)\n\ntype StructError struct {\n Message string `json:"message,omitempty"`\n Code ErrorCode `json:"errorCode"`\n}\n\nfunc (e *StructError) Error() string {\n return e.Message\n}\n\ntype Service struct {\n MightGoWrong() *StructError\n}\n')),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"export enum ErrorCode {\n Bar = 2,\n Foo = 1,\n}\n\nexport interface StructError {\n message?:string;\n errorCode:ErrorCode;\n}\n\nexport interface ServiceClient {\n mightGoWrong(): Promise;\n}\n")))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/935f2afb.f34fe3ee.js b/assets/js/935f2afb.32db5421.js similarity index 93% rename from assets/js/935f2afb.f34fe3ee.js rename to assets/js/935f2afb.32db5421.js index c1e1edf..8eb458c 100644 --- a/assets/js/935f2afb.f34fe3ee.js +++ b/assets/js/935f2afb.32db5421.js @@ -1 +1 @@ -"use strict";(self.webpackChunkfoomo=self.webpackChunkfoomo||[]).push([[53],{1109:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"generalSidebar":[{"type":"link","label":"General guide","href":"/docs/general/","docId":"general/index"},{"type":"category","label":"Setup","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Workplace","href":"/docs/general/setup/workplace","docId":"general/setup/workplace"},{"type":"link","label":"Computer","href":"/docs/general/setup/computer","docId":"general/setup/computer"}]},{"type":"category","label":"Work","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Working as a software developer","href":"/docs/general/work/general","docId":"general/work/general"},{"type":"link","label":"Working remotely","href":"/docs/general/work/remote-work","docId":"general/work/remote-work"}]},{"type":"link","label":"Package managers","href":"/docs/general/package-managers","docId":"general/package-managers"},{"type":"category","label":"Technologies","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"SSE Server Sent Events","href":"/docs/general/technologies/sse","docId":"general/technologies/SSE"}]},{"type":"link","label":"(Random) essentials","href":"/docs/general/essentials","docId":"general/essentials"},{"type":"link","label":"Security","href":"/docs/general/security","docId":"general/security"},{"type":"category","label":"utilities","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"k9s","href":"/docs/general/utilities/k9s","docId":"general/utilities/k9s"}]}],"backendSidebar":[{"type":"link","label":"Backend Guide","href":"/docs/backend/","docId":"backend/index"},{"type":"link","label":"RTFM","href":"/docs/backend/rtfm","docId":"backend/rtfm"},{"type":"link","label":"Setup","href":"/docs/backend/setup","docId":"backend/setup"},{"type":"category","label":"Go by example","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Defer","href":"/docs/backend/go-by-example/defer","docId":"backend/go-by-example/defer"},{"type":"link","label":"Panic and Recover","href":"/docs/backend/go-by-example/panic-and-recover","docId":"backend/go-by-example/panic-and-recover"},{"type":"link","label":"Maps","href":"/docs/backend/go-by-example/nil-maps","docId":"backend/go-by-example/nil-maps"},{"type":"link","label":"Ranging and Looping","href":"/docs/backend/go-by-example/ranging","docId":"backend/go-by-example/ranging"},{"type":"link","label":"CLI applications","href":"/docs/backend/go-by-example/cli-applications","docId":"backend/go-by-example/cli-applications"},{"type":"link","label":"Context","href":"/docs/backend/go-by-example/context","docId":"backend/go-by-example/context"},{"type":"link","label":"Embed","href":"/docs/backend/go-by-example/embed","docId":"backend/go-by-example/embed"},{"type":"link","label":"Files","href":"/docs/backend/go-by-example/files","docId":"backend/go-by-example/files"},{"type":"link","label":"Go Routines and Channels","href":"/docs/backend/go-by-example/goroutines-and-channels","docId":"backend/go-by-example/goroutines-and-channels"},{"type":"link","label":"HTTP Client and Server","href":"/docs/backend/go-by-example/http","docId":"backend/go-by-example/http"},{"type":"link","label":"Interfaces","href":"/docs/backend/go-by-example/interfaces","docId":"backend/go-by-example/interfaces"},{"type":"link","label":"Map Races","href":"/docs/backend/go-by-example/map-racing","docId":"backend/go-by-example/map-racing"},{"type":"link","label":"MongoDB","href":"/docs/backend/go-by-example/mongodb","docId":"backend/go-by-example/mongodb"},{"type":"link","label":"Reflection","href":"/docs/backend/go-by-example/reflection","docId":"backend/go-by-example/reflection"},{"type":"link","label":"Type Casting","href":"/docs/backend/go-by-example/type-casting","docId":"backend/go-by-example/type-casting"},{"type":"link","label":"waitgroups","href":"/docs/backend/go-by-example/waitgroups","docId":"backend/go-by-example/waitgroups"},{"type":"link","label":"Yaml magic","href":"/docs/backend/go-by-example/yaml-magic","docId":"backend/go-by-example/yaml-magic"}]},{"type":"link","label":"Gograpple","href":"/docs/backend/gograpple","docId":"backend/gograpple"},{"type":"category","label":"Profiling Go applications","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"runtime pprof","href":"/docs/backend/profiling/pprof","docId":"backend/profiling/pprof"}],"href":"/docs/backend/profiling/"}],"frontendSidebar":[{"type":"link","label":"Frontend Guide","href":"/docs/frontend/","docId":"frontend/index"},{"type":"link","label":"CSS","href":"/docs/frontend/css","docId":"frontend/css"},{"type":"link","label":"RTFM","href":"/docs/frontend/rtfm","docId":"frontend/rtfm"},{"type":"link","label":"Setup","href":"/docs/frontend/setup","docId":"frontend/setup"},{"type":"link","label":"Stack","href":"/docs/frontend/stack","docId":"frontend/stack"},{"type":"link","label":"Performance","href":"/docs/frontend/performance","docId":"frontend/performance"},{"type":"category","label":"TypeScript","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Objects","href":"/docs/frontend/typescript/objects","docId":"frontend/typescript/objects"},{"type":"link","label":"Spreading","href":"/docs/frontend/typescript/spreading","docId":"frontend/typescript/spreading"}]},{"type":"link","label":"Debugging in JavaScript","href":"/docs/frontend/debugging_js","docId":"frontend/debugging_js"},{"type":"link","label":"Pittfals","href":"/docs/frontend/pitfalls","docId":"frontend/pitfalls"},{"type":"link","label":"vscode","href":"/docs/frontend/vscode","docId":"frontend/vscode"}],"devopsSidebar":[{"type":"link","label":"Devops Guide","href":"/docs/devops/","docId":"devops/index"},{"type":"category","label":"Kubernetes","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Spot Instance Node Pools","href":"/docs/devops/kubernetes/spot-instance-node-pools","docId":"devops/kubernetes/spot-instance-node-pools"}]},{"type":"link","label":"k8s","href":"/docs/devops/k8s","docId":"devops/k8s"},{"type":"category","label":"Monitoring","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Intro","href":"/docs/devops/monitoring/intro","docId":"devops/monitoring/intro"},{"type":"link","label":"Grafana","href":"/docs/devops/monitoring/grafana","docId":"devops/monitoring/grafana"},{"type":"link","label":"Jaeger","href":"/docs/devops/monitoring/jaeger","docId":"devops/monitoring/jaeger"}]},{"type":"category","label":"Infrastructure","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Conventions","href":"/docs/devops/infrastructure/conventions","docId":"devops/infrastructure/conventions"}]},{"type":"link","label":"Bookmarks","href":"/docs/devops/bookmarks","docId":"devops/bookmarks"}],"projectsSidebar":[{"type":"link","label":"Overview","href":"/docs/projects/","docId":"projects/index"},{"type":"link","label":"Architecture","href":"/docs/projects/architecture","docId":"projects/architecture"},{"type":"category","label":"CMS","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"contentserver","href":"/docs/projects/cms/contentserver","docId":"projects/cms/contentserver"},{"type":"link","label":"contentful","href":"/docs/projects/cms/contentful","docId":"projects/cms/contentful"},{"type":"category","label":"Gocontentful","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Getting started","href":"/docs/projects/cms/gocontentful/getting-started","docId":"projects/cms/gocontentful/getting-started"},{"type":"link","label":"Play with the test API","href":"/docs/projects/cms/gocontentful/test-api","docId":"projects/cms/gocontentful/test-api"},{"type":"link","label":"Working with the Gocontentful API","href":"/docs/projects/cms/gocontentful/working-with-gocontentful-api","docId":"projects/cms/gocontentful/working-with-gocontentful-api"},{"type":"link","label":"Caching","href":"/docs/projects/cms/gocontentful/caching","docId":"projects/cms/gocontentful/caching"},{"type":"link","label":"API Reference","href":"/docs/projects/cms/gocontentful/api-reference","docId":"projects/cms/gocontentful/api-reference"}],"href":"/docs/projects/cms/gocontentful/"}],"href":"/docs/projects/cms/"},{"type":"link","label":"gograpple","href":"/docs/projects/gograpple","docId":"projects/gograpple"},{"type":"category","label":"gotsrpc","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Getting started","href":"/docs/projects/gotsrpc/getting-started","docId":"projects/gotsrpc/getting-started"},{"type":"category","label":"cli","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"gotsrpc.yaml","href":"/docs/projects/gotsrpc/cli/gotsrpc.yaml","docId":"projects/gotsrpc/cli/gotsrpc.yaml"}],"href":"/docs/projects/gotsrpc/cli/"},{"type":"link","label":"Workflow","href":"/docs/projects/gotsrpc/workflow","docId":"projects/gotsrpc/workflow"},{"type":"category","label":"Service Interfaces","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Value Objects","href":"/docs/projects/gotsrpc/service-interfaces/value-objects","docId":"projects/gotsrpc/service-interfaces/value-objects"},{"type":"link","label":"Errors","href":"/docs/projects/gotsrpc/service-interfaces/errors","docId":"projects/gotsrpc/service-interfaces/errors"}],"href":"/docs/projects/gotsrpc/service-interfaces/"},{"type":"link","label":"TypeScript client transport","href":"/docs/projects/gotsrpc/client-transport","docId":"projects/gotsrpc/client-transport"},{"type":"category","label":"Playground","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Hello, World!","href":"/docs/projects/gotsrpc/playground/hello-world","docId":"projects/gotsrpc/playground/hello-world"},{"type":"link","label":"Wheel of Fortune","href":"/docs/projects/gotsrpc/playground/wheel-of-fortune","docId":"projects/gotsrpc/playground/wheel-of-fortune"},{"type":"link","label":"Todos","href":"/docs/projects/gotsrpc/playground/todos","docId":"projects/gotsrpc/playground/todos"},{"type":"link","label":"Union Errors","href":"/docs/projects/gotsrpc/playground/union-errors","docId":"projects/gotsrpc/playground/union-errors"},{"type":"link","label":"Playground","href":"/docs/projects/gotsrpc/playground/playground","docId":"projects/gotsrpc/playground/playground"}],"href":"/docs/projects/gotsrpc/playground/"},{"type":"link","label":"Protocol","href":"/docs/projects/gotsrpc/protocol","docId":"projects/gotsrpc/protocol"}],"href":"/docs/projects/gotsrpc/"},{"type":"category","label":"keel","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Circuit Breaker","href":"/docs/projects/keel/circuit-breaker/","docId":"projects/keel/circuit-breaker/index"}],"href":"/docs/projects/keel/"},{"type":"link","label":"pagespeed exporter","href":"/docs/projects/pagespeed-exporter","docId":"projects/pagespeed-exporter"},{"type":"link","label":"webgrapple","href":"/docs/projects/webgrapple","docId":"projects/webgrapple"}]},"docs":{"backend/go-by-example/cli-applications":{"id":"backend/go-by-example/cli-applications","title":"CLI applications","description":"The following example has some modifications in order to run in the playground. The Go Playground does not allow flags to be passed so it\'s recommended you","sidebar":"backendSidebar"},"backend/go-by-example/context":{"id":"backend/go-by-example/context","title":"Context","description":"The `context` package in go provides a way for request-scoped values to be passed between all goroutines that are involved in handling a request.","sidebar":"backendSidebar"},"backend/go-by-example/defer":{"id":"backend/go-by-example/defer","title":"Defer","description":"In a normal Go application, control flows from the top to the bottom of any function that we call (this is if you don\'t use branching or looping).","sidebar":"backendSidebar"},"backend/go-by-example/embed":{"id":"backend/go-by-example/embed","title":"Embed","description":"https://gobyexample.com/embed-directive","sidebar":"backendSidebar"},"backend/go-by-example/files":{"id":"backend/go-by-example/files","title":"Files","description":"There are multiple packages we can utilize for reading files in a go program. We\'ll go over the most commonly used ones in this section.","sidebar":"backendSidebar"},"backend/go-by-example/goroutines-and-channels":{"id":"backend/go-by-example/goroutines-and-channels","title":"Go Routines and Channels","description":"Go Routines","sidebar":"backendSidebar"},"backend/go-by-example/http":{"id":"backend/go-by-example/http","title":"HTTP Client and Server","description":"The HTTP protocol is used to communicate between Client and Server. The `net/http` package provides all methods needed to implement a client and","sidebar":"backendSidebar"},"backend/go-by-example/interfaces":{"id":"backend/go-by-example/interfaces","title":"Interfaces","description":"In go you can define a type using a set of methods by using the `interface` keyword.","sidebar":"backendSidebar"},"backend/go-by-example/map-racing":{"id":"backend/go-by-example/map-racing","title":"Map Races","description":"","sidebar":"backendSidebar"},"backend/go-by-example/mongodb":{"id":"backend/go-by-example/mongodb","title":"MongoDB","description":"Make sure to use the official golang mongo driver:","sidebar":"backendSidebar"},"backend/go-by-example/nil-maps":{"id":"backend/go-by-example/nil-maps","title":"Maps","description":"Maps are unordered key value pairs where each key is unique.","sidebar":"backendSidebar"},"backend/go-by-example/panic-and-recover":{"id":"backend/go-by-example/panic-and-recover","title":"Panic and Recover","description":"Panic","sidebar":"backendSidebar"},"backend/go-by-example/ranging":{"id":"backend/go-by-example/ranging","title":"Ranging and Looping","description":"{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"generalSidebar":[{"type":"link","label":"General guide","href":"/docs/general/","docId":"general/index"},{"type":"category","label":"Setup","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Workplace","href":"/docs/general/setup/workplace","docId":"general/setup/workplace"},{"type":"link","label":"Computer","href":"/docs/general/setup/computer","docId":"general/setup/computer"}]},{"type":"category","label":"Work","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Working as a software developer","href":"/docs/general/work/general","docId":"general/work/general"},{"type":"link","label":"Working remotely","href":"/docs/general/work/remote-work","docId":"general/work/remote-work"}]},{"type":"link","label":"Package managers","href":"/docs/general/package-managers","docId":"general/package-managers"},{"type":"category","label":"Technologies","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"SSE Server Sent Events","href":"/docs/general/technologies/sse","docId":"general/technologies/SSE"}]},{"type":"link","label":"(Random) essentials","href":"/docs/general/essentials","docId":"general/essentials"},{"type":"link","label":"Security","href":"/docs/general/security","docId":"general/security"},{"type":"category","label":"utilities","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"k9s","href":"/docs/general/utilities/k9s","docId":"general/utilities/k9s"}]}],"backendSidebar":[{"type":"link","label":"Backend Guide","href":"/docs/backend/","docId":"backend/index"},{"type":"link","label":"RTFM","href":"/docs/backend/rtfm","docId":"backend/rtfm"},{"type":"link","label":"Setup","href":"/docs/backend/setup","docId":"backend/setup"},{"type":"category","label":"Go by example","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Defer","href":"/docs/backend/go-by-example/defer","docId":"backend/go-by-example/defer"},{"type":"link","label":"Panic and Recover","href":"/docs/backend/go-by-example/panic-and-recover","docId":"backend/go-by-example/panic-and-recover"},{"type":"link","label":"Maps","href":"/docs/backend/go-by-example/nil-maps","docId":"backend/go-by-example/nil-maps"},{"type":"link","label":"Ranging and Looping","href":"/docs/backend/go-by-example/ranging","docId":"backend/go-by-example/ranging"},{"type":"link","label":"CLI applications","href":"/docs/backend/go-by-example/cli-applications","docId":"backend/go-by-example/cli-applications"},{"type":"link","label":"Context","href":"/docs/backend/go-by-example/context","docId":"backend/go-by-example/context"},{"type":"link","label":"Embed","href":"/docs/backend/go-by-example/embed","docId":"backend/go-by-example/embed"},{"type":"link","label":"Files","href":"/docs/backend/go-by-example/files","docId":"backend/go-by-example/files"},{"type":"link","label":"Go Routines and Channels","href":"/docs/backend/go-by-example/goroutines-and-channels","docId":"backend/go-by-example/goroutines-and-channels"},{"type":"link","label":"HTTP Client and Server","href":"/docs/backend/go-by-example/http","docId":"backend/go-by-example/http"},{"type":"link","label":"Interfaces","href":"/docs/backend/go-by-example/interfaces","docId":"backend/go-by-example/interfaces"},{"type":"link","label":"Map Races","href":"/docs/backend/go-by-example/map-racing","docId":"backend/go-by-example/map-racing"},{"type":"link","label":"MongoDB","href":"/docs/backend/go-by-example/mongodb","docId":"backend/go-by-example/mongodb"},{"type":"link","label":"Reflection","href":"/docs/backend/go-by-example/reflection","docId":"backend/go-by-example/reflection"},{"type":"link","label":"Type Casting","href":"/docs/backend/go-by-example/type-casting","docId":"backend/go-by-example/type-casting"},{"type":"link","label":"waitgroups","href":"/docs/backend/go-by-example/waitgroups","docId":"backend/go-by-example/waitgroups"},{"type":"link","label":"Yaml magic","href":"/docs/backend/go-by-example/yaml-magic","docId":"backend/go-by-example/yaml-magic"}]},{"type":"link","label":"Gograpple","href":"/docs/backend/gograpple","docId":"backend/gograpple"},{"type":"category","label":"Profiling Go applications","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"runtime pprof","href":"/docs/backend/profiling/pprof","docId":"backend/profiling/pprof"}],"href":"/docs/backend/profiling/"}],"frontendSidebar":[{"type":"link","label":"Frontend Guide","href":"/docs/frontend/","docId":"frontend/index"},{"type":"link","label":"CSS","href":"/docs/frontend/css","docId":"frontend/css"},{"type":"link","label":"RTFM","href":"/docs/frontend/rtfm","docId":"frontend/rtfm"},{"type":"link","label":"Setup","href":"/docs/frontend/setup","docId":"frontend/setup"},{"type":"link","label":"Stack","href":"/docs/frontend/stack","docId":"frontend/stack"},{"type":"link","label":"Performance","href":"/docs/frontend/performance","docId":"frontend/performance"},{"type":"category","label":"TypeScript","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Objects","href":"/docs/frontend/typescript/objects","docId":"frontend/typescript/objects"},{"type":"link","label":"Spreading","href":"/docs/frontend/typescript/spreading","docId":"frontend/typescript/spreading"}]},{"type":"link","label":"Debugging in JavaScript","href":"/docs/frontend/debugging_js","docId":"frontend/debugging_js"},{"type":"link","label":"Pittfals","href":"/docs/frontend/pitfalls","docId":"frontend/pitfalls"},{"type":"link","label":"vscode","href":"/docs/frontend/vscode","docId":"frontend/vscode"}],"devopsSidebar":[{"type":"link","label":"Devops Guide","href":"/docs/devops/","docId":"devops/index"},{"type":"category","label":"Kubernetes","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Spot Instance Node Pools","href":"/docs/devops/kubernetes/spot-instance-node-pools","docId":"devops/kubernetes/spot-instance-node-pools"}]},{"type":"link","label":"k8s","href":"/docs/devops/k8s","docId":"devops/k8s"},{"type":"category","label":"Monitoring","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Intro","href":"/docs/devops/monitoring/intro","docId":"devops/monitoring/intro"},{"type":"link","label":"Grafana","href":"/docs/devops/monitoring/grafana","docId":"devops/monitoring/grafana"},{"type":"link","label":"Jaeger","href":"/docs/devops/monitoring/jaeger","docId":"devops/monitoring/jaeger"}]},{"type":"category","label":"Infrastructure","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Conventions","href":"/docs/devops/infrastructure/conventions","docId":"devops/infrastructure/conventions"}]},{"type":"link","label":"Bookmarks","href":"/docs/devops/bookmarks","docId":"devops/bookmarks"}],"projectsSidebar":[{"type":"link","label":"Overview","href":"/docs/projects/","docId":"projects/index"},{"type":"link","label":"Architecture","href":"/docs/projects/architecture","docId":"projects/architecture"},{"type":"category","label":"CMS","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"contentserver","href":"/docs/projects/cms/contentserver","docId":"projects/cms/contentserver"},{"type":"link","label":"contentful","href":"/docs/projects/cms/contentful","docId":"projects/cms/contentful"},{"type":"category","label":"Gocontentful","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Getting started","href":"/docs/projects/cms/gocontentful/getting-started","docId":"projects/cms/gocontentful/getting-started"},{"type":"link","label":"Play with the test API","href":"/docs/projects/cms/gocontentful/test-api","docId":"projects/cms/gocontentful/test-api"},{"type":"link","label":"Working with the Gocontentful API","href":"/docs/projects/cms/gocontentful/working-with-gocontentful-api","docId":"projects/cms/gocontentful/working-with-gocontentful-api"},{"type":"link","label":"Caching","href":"/docs/projects/cms/gocontentful/caching","docId":"projects/cms/gocontentful/caching"},{"type":"link","label":"API Reference","href":"/docs/projects/cms/gocontentful/api-reference","docId":"projects/cms/gocontentful/api-reference"}],"href":"/docs/projects/cms/gocontentful/"}],"href":"/docs/projects/cms/"},{"type":"link","label":"gograpple","href":"/docs/projects/gograpple","docId":"projects/gograpple"},{"type":"category","label":"gotsrpc","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Getting started","href":"/docs/projects/gotsrpc/getting-started","docId":"projects/gotsrpc/getting-started"},{"type":"category","label":"cli","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"gotsrpc.yaml","href":"/docs/projects/gotsrpc/cli/gotsrpc.yaml","docId":"projects/gotsrpc/cli/gotsrpc.yaml"}],"href":"/docs/projects/gotsrpc/cli/"},{"type":"link","label":"Workflow","href":"/docs/projects/gotsrpc/workflow","docId":"projects/gotsrpc/workflow"},{"type":"category","label":"Service Interfaces","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Value Objects","href":"/docs/projects/gotsrpc/service-interfaces/value-objects","docId":"projects/gotsrpc/service-interfaces/value-objects"},{"type":"link","label":"Errors","href":"/docs/projects/gotsrpc/service-interfaces/errors","docId":"projects/gotsrpc/service-interfaces/errors"}],"href":"/docs/projects/gotsrpc/service-interfaces/"},{"type":"link","label":"TypeScript client transport","href":"/docs/projects/gotsrpc/client-transport","docId":"projects/gotsrpc/client-transport"},{"type":"category","label":"Playground","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Hello, World!","href":"/docs/projects/gotsrpc/playground/hello-world","docId":"projects/gotsrpc/playground/hello-world"},{"type":"link","label":"Wheel of Fortune","href":"/docs/projects/gotsrpc/playground/wheel-of-fortune","docId":"projects/gotsrpc/playground/wheel-of-fortune"},{"type":"link","label":"Todos","href":"/docs/projects/gotsrpc/playground/todos","docId":"projects/gotsrpc/playground/todos"},{"type":"link","label":"Union Errors","href":"/docs/projects/gotsrpc/playground/union-errors","docId":"projects/gotsrpc/playground/union-errors"},{"type":"link","label":"Playground","href":"/docs/projects/gotsrpc/playground/playground","docId":"projects/gotsrpc/playground/playground"}],"href":"/docs/projects/gotsrpc/playground/"},{"type":"link","label":"Protocol","href":"/docs/projects/gotsrpc/protocol","docId":"projects/gotsrpc/protocol"}],"href":"/docs/projects/gotsrpc/"},{"type":"category","label":"keel","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Circuit Breaker","href":"/docs/projects/keel/circuit-breaker/","docId":"projects/keel/circuit-breaker/index"}],"href":"/docs/projects/keel/"},{"type":"link","label":"pagespeed exporter","href":"/docs/projects/pagespeed-exporter","docId":"projects/pagespeed-exporter"},{"type":"link","label":"webgrapple","href":"/docs/projects/webgrapple","docId":"projects/webgrapple"}]},"docs":{"backend/go-by-example/cli-applications":{"id":"backend/go-by-example/cli-applications","title":"CLI applications","description":"The following example has some modifications in order to run in the playground. The Go Playground does not allow flags to be passed so it\'s recommended you","sidebar":"backendSidebar"},"backend/go-by-example/context":{"id":"backend/go-by-example/context","title":"Context","description":"The `context` package in go provides a way for request-scoped values to be passed between all goroutines that are involved in handling a request.","sidebar":"backendSidebar"},"backend/go-by-example/defer":{"id":"backend/go-by-example/defer","title":"Defer","description":"In a normal Go application, control flows from the top to the bottom of any function that we call (this is if you don\'t use branching or looping).","sidebar":"backendSidebar"},"backend/go-by-example/embed":{"id":"backend/go-by-example/embed","title":"Embed","description":"https://gobyexample.com/embed-directive","sidebar":"backendSidebar"},"backend/go-by-example/files":{"id":"backend/go-by-example/files","title":"Files","description":"There are multiple packages we can utilize for reading files in a go program. We\'ll go over the most commonly used ones in this section.","sidebar":"backendSidebar"},"backend/go-by-example/goroutines-and-channels":{"id":"backend/go-by-example/goroutines-and-channels","title":"Go Routines and Channels","description":"Go Routines","sidebar":"backendSidebar"},"backend/go-by-example/http":{"id":"backend/go-by-example/http","title":"HTTP Client and Server","description":"The HTTP protocol is used to communicate between Client and Server. The `net/http` package provides all methods needed to implement a client and","sidebar":"backendSidebar"},"backend/go-by-example/interfaces":{"id":"backend/go-by-example/interfaces","title":"Interfaces","description":"In go you can define a type using a set of methods by using the `interface` keyword.","sidebar":"backendSidebar"},"backend/go-by-example/map-racing":{"id":"backend/go-by-example/map-racing","title":"Map Races","description":"","sidebar":"backendSidebar"},"backend/go-by-example/mongodb":{"id":"backend/go-by-example/mongodb","title":"MongoDB","description":"Make sure to use the official golang mongo driver:","sidebar":"backendSidebar"},"backend/go-by-example/nil-maps":{"id":"backend/go-by-example/nil-maps","title":"Maps","description":"Maps are unordered key value pairs where each key is unique.","sidebar":"backendSidebar"},"backend/go-by-example/panic-and-recover":{"id":"backend/go-by-example/panic-and-recover","title":"Panic and Recover","description":"Panic","sidebar":"backendSidebar"},"backend/go-by-example/ranging":{"id":"backend/go-by-example/ranging","title":"Ranging and Looping","description":"{a.d(t,{Zo:()=>c,kt:()=>g});var n=a(7294);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function i(e){for(var t=1;t=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var p=n.createContext({}),o=function(e){var t=n.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):i(i({},t),e)),a},c=function(e){var t=o(e.components);return n.createElement(p.Provider,{value:t},e.children)},u="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},d=n.forwardRef((function(e,t){var a=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=o(a),d=r,g=u["".concat(p,".").concat(d)]||u[d]||m[d]||l;return a?n.createElement(g,i(i({ref:t},c),{},{components:a})):n.createElement(g,i({ref:t},c))}));function g(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=a.length,i=new Array(l);i[0]=d;var s={};for(var p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s[u]="string"==typeof e?e:r,i[1]=s;for(var o=2;o{a.r(t),a.d(t,{assets:()=>p,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>s,toc:()=>o});var n=a(7462),r=(a(7294),a(3905));const l={sidebar_position:1,toc_max_heading_level:5},i="Value Objects",s={unversionedId:"projects/gotsrpc/service-interfaces/value-objects",id:"projects/gotsrpc/service-interfaces/value-objects",title:"Value Objects",description:"Typically value objects will be serialized / marshalled as JSON. Please refer to this documentation:",source:"@site/docs/projects/gotsrpc/service-interfaces/value-objects.md",sourceDirName:"projects/gotsrpc/service-interfaces",slug:"/projects/gotsrpc/service-interfaces/value-objects",permalink:"/docs/projects/gotsrpc/service-interfaces/value-objects",draft:!1,editUrl:"https://github.com/foomo/foomo-docs/tree/main/foomo/docs/projects/gotsrpc/service-interfaces/value-objects.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,toc_max_heading_level:5},sidebar:"projectsSidebar",previous:{title:"Service Interfaces",permalink:"/docs/projects/gotsrpc/service-interfaces/"},next:{title:"Errors",permalink:"/docs/projects/gotsrpc/service-interfaces/errors"}},p={},o=[{value:"Scalar types",id:"scalar-types",level:2},{value:"Supported in Go and TypeScript",id:"supported-in-go-and-typescript",level:3},{value:"Numerics / numbers",id:"numerics--numbers",level:3},{value:"Type Aliases",id:"type-aliases",level:3},{value:"Enumerations",id:"enumerations",level:2},{value:"Slices",id:"slices",level:2},{value:"Scalar types",id:"scalar-types-1",level:3},{value:"Other slice type examples",id:"other-slice-type-examples",level:3},{value:"Structs",id:"structs",level:4},{value:"Nested slices",id:"nested-slices",level:4},{value:"Maps / Records",id:"maps--records",level:2},{value:"Scalars",id:"scalars",level:3},{value:"Structs",id:"structs-1",level:3},{value:"Slices",id:"slices-1",level:3},{value:"Map types",id:"map-types",level:2},{value:"Nested map types",id:"nested-map-types",level:2},{value:"Structs / Interfaces",id:"structs--interfaces",level:2},{value:"Field names",id:"field-names",level:3},{value:"Default Go => TypeScript",id:"default-go--typescript",level:4},{value:"Idiomatic field names",id:"idiomatic-field-names",level:4},{value:"Optional and nullable fields",id:"optional-and-nullable-fields",level:3},{value:"Hiding values from the client",id:"hiding-values-from-the-client",level:3},{value:"Union Types",id:"union-types",level:3}],c={toc:o},u="wrapper";function m(e){let{components:t,...a}=e;return(0,r.kt)(u,(0,n.Z)({},c,a,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"value-objects"},"Value Objects"),(0,r.kt)("p",null,"Typically value objects will be serialized / marshalled as JSON. Please refer to this documentation:"),(0,r.kt)("p",null,(0,r.kt)("a",{parentName:"p",href:"https://pkg.go.dev/encoding/json#Marshal"},"https://pkg.go.dev/encoding/json#Marshal")),(0,r.kt)("admonition",{type:"note"},(0,r.kt)("p",{parentName:"admonition"},"This is just a few basic examples, that show the basics of mapping Go types to idiomatic TypeScript types.")),(0,r.kt)("h2",{id:"scalar-types"},"Scalar types"),(0,r.kt)("h3",{id:"supported-in-go-and-typescript"},"Supported in Go and TypeScript"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Go"),(0,r.kt)("th",{parentName:"tr",align:null},"TypeScript"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"string"),(0,r.kt)("td",{parentName:"tr",align:null},"string")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"bool"),(0,r.kt)("td",{parentName:"tr",align:null},"boolean")))),(0,r.kt)("h3",{id:"numerics--numbers"},"Numerics / numbers"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Go"),(0,r.kt)("th",{parentName:"tr",align:null},"TypeScript"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"int, int8, int16, float32, float64 ..."),(0,r.kt)("td",{parentName:"tr",align:null},"number")))),(0,r.kt)("h3",{id:"type-aliases"},"Type Aliases"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type Greeting string\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Greeting = string;\n")),(0,r.kt)("h2",{id:"enumerations"},"Enumerations"),(0,r.kt)("p",null,"Go does not support enumerations, but ",(0,r.kt)("inlineCode",{parentName:"p"},"gotsrpc")," will translate constants to TypeScripts enums:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Pet string\n\nconst (\n Cat Pet = "cat"\n Dog Pet = "dog"\n Fish Pet = "fish"\n)\n\ntype SeatCount int\n\nconst (\n TwoSeats SeatCount = 2\n FiveSeats SeatCount = 5\n SevenSeats SeatCount = 7\n)\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},'export enum Pet {\n Cat = "cat",\n Dog = "dog",\n Fish = "fish",\n}\n\nexport enum SeatCount {\n FiveSeats = 5,\n SevenSeats = 7,\n TwoSeats = 2,\n}\n')),(0,r.kt)("h2",{id:"slices"},"Slices"),(0,r.kt)("p",null,"Slices are nilable in Go, thus they can be null in TypeScript. They translate to ",(0,r.kt)("inlineCode",{parentName:"p"},"Array|null")," in TypeScript."),(0,r.kt)("h3",{id:"scalar-types-1"},"Scalar types"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[]string\n[]int\n// other numeric types\n[]bool\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null;\nArray | null;\n// all numeric types are numbers\nArray | null;\n")),(0,r.kt)("h3",{id:"other-slice-type-examples"},"Other slice type examples"),(0,r.kt)("h4",{id:"structs"},"Structs"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[]Car\n[]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null;\nArray | null;\n")),(0,r.kt)("h4",{id:"nested-slices"},"Nested slices"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[][]string\n[][]int\n// ...\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null> | null;\nArray | null> | null;\n// ...\n")),(0,r.kt)("h2",{id:"maps--records"},"Maps / Records"),(0,r.kt)("p",null,"Like slices Go maps are nilable. They translate to ",(0,r.kt)("inlineCode",{parentName:"p"},"Record|null")," in TypeScript."),(0,r.kt)("h3",{id:"scalars"},"Scalars"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string]string\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null;\n")),(0,r.kt)("h3",{id:"structs-1"},"Structs"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null;\n")),(0,r.kt)("h3",{id:"slices-1"},"Slices"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string][]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null> | null;\n")),(0,r.kt)("h2",{id:"map-types"},"Map types"),(0,r.kt)("p",null,"Go and TypeScript support map / Record types:"),(0,r.kt)("admonition",{type:"tip"},(0,r.kt)("p",{parentName:"admonition"},"Scalar types / type aliases are of particular value when using maps, because they can add strong semantics:")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type CarDirectory map[ProductID]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type CarDirectory = Record | null;\n")),(0,r.kt)("h2",{id:"nested-map-types"},"Nested map types"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type BrandID string\ntype BrandCarDirectory map[BrandID]map[ProductID]*Car\n// or\ntype BrandCarDirectory map[BrandID]CarDirectory\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type BrandID = string;\ntype BrandCarDirectory = Record<\n BrandID,\n Record | null\n> | null;\n// or\ntype BrandCarDirectory = Record | null;\n")),(0,r.kt)("h2",{id:"structs--interfaces"},"Structs / Interfaces"),(0,r.kt)("p",null,"Arbitrary Types can be composed in structs."),(0,r.kt)("h3",{id:"field-names"},"Field names"),(0,r.kt)("p",null,"Naming conventions are different between Go and TypeScript. In order to bridge the gap between Go and TypeScript Go struct fields can be ",(0,r.kt)("a",{parentName:"p",href:"https://pkg.go.dev/encoding/json#Marshal"},"annotated with tags"),". In this way idiomatic naming of fields can be can be provided for both languages and the translation will be automatic."),(0,r.kt)("h4",{id:"default-go--typescript"},"Default Go => TypeScript"),(0,r.kt)("p",null,"Without json tags TypeScript field names will be like in Go, which is not idiomatic for TypeScript."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type Car struct {\n GoCase string\n CamelCase string\n SnakeCase string\n}\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"interface Car {\n GoCase:string;\n CamelCase:string;\n SnakeCase:string;\n}\n")),(0,r.kt)("h4",{id:"idiomatic-field-names"},"Idiomatic field names"),(0,r.kt)("p",null,"Json tags allow controlling the name in TypeScript."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Car struct {\n CamelCase string `json:"camelCase"`\n SnakeCase string `json:"snake_case"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"interface Car {\n camelCase:string;\n snake_case:string;\n}\n")),(0,r.kt)("h3",{id:"optional-and-nullable-fields"},"Optional and nullable fields"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Basic struct {\n Value string `json:"value"`\n OptionalValue string `json:"optionalValue,omitempty"`\n NullableValue *string `json:"nullableValue"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Basic interface {\n value:string;\n optionalValue?:string;\n nullableValue:string|null;\n}\n")),(0,r.kt)("h3",{id:"hiding-values-from-the-client"},"Hiding values from the client"),(0,r.kt)("p",null,"The Go json tag ",(0,r.kt)("inlineCode",{parentName:"p"},'`json:"-"`')," on a struct allows it to:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"hide fields from clients"),(0,r.kt)("li",{parentName:"ul"},"prevents clients from setting them in JSON Unmarshalling")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Basic struct {\n Value string `json:"value"`\n Secret string `json:"-"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Basic interface {\n value:string;\n}\n")),(0,r.kt)("h3",{id:"union-types"},"Union Types"),(0,r.kt)("p",null,"When static types seem to be in the way"))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/aedc5931.fbb9b81b.js b/assets/js/aedc5931.fbb9b81b.js new file mode 100644 index 0000000..078eb98 --- /dev/null +++ b/assets/js/aedc5931.fbb9b81b.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkfoomo=self.webpackChunkfoomo||[]).push([[3964],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>g});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),o=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=o(e.components);return a.createElement(p.Provider,{value:t},e.children)},u="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},d=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=o(n),d=r,g=u["".concat(p,".").concat(d)]||u[d]||m[d]||l;return n?a.createElement(g,i(i({ref:t},c),{},{components:n})):a.createElement(g,i({ref:t},c))}));function g(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=d;var s={};for(var p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s[u]="string"==typeof e?e:r,i[1]=s;for(var o=2;o{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>s,toc:()=>o});var a=n(7462),r=(n(7294),n(3905));const l={sidebar_position:1,toc_max_heading_level:5},i="Value Objects",s={unversionedId:"projects/gotsrpc/service-interfaces/value-objects",id:"projects/gotsrpc/service-interfaces/value-objects",title:"Value Objects",description:"Typically value objects will be serialized / marshalled as JSON. Please refer to this documentation:",source:"@site/docs/projects/gotsrpc/service-interfaces/value-objects.md",sourceDirName:"projects/gotsrpc/service-interfaces",slug:"/projects/gotsrpc/service-interfaces/value-objects",permalink:"/docs/projects/gotsrpc/service-interfaces/value-objects",draft:!1,editUrl:"https://github.com/foomo/foomo-docs/tree/main/foomo/docs/projects/gotsrpc/service-interfaces/value-objects.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,toc_max_heading_level:5},sidebar:"projectsSidebar",previous:{title:"Service Interfaces",permalink:"/docs/projects/gotsrpc/service-interfaces/"},next:{title:"Errors",permalink:"/docs/projects/gotsrpc/service-interfaces/errors"}},p={},o=[{value:"Scalar types",id:"scalar-types",level:2},{value:"Supported in Go and TypeScript",id:"supported-in-go-and-typescript",level:3},{value:"Numerics / numbers",id:"numerics--numbers",level:3},{value:"Type Aliases",id:"type-aliases",level:3},{value:"Enumerations",id:"enumerations",level:2},{value:"Slices",id:"slices",level:2},{value:"Scalar types",id:"scalar-types-1",level:3},{value:"Other slice type examples",id:"other-slice-type-examples",level:3},{value:"Structs",id:"structs",level:4},{value:"Nested slices",id:"nested-slices",level:4},{value:"Maps / Records",id:"maps--records",level:2},{value:"Scalars",id:"scalars",level:3},{value:"Structs",id:"structs-1",level:3},{value:"Slices",id:"slices-1",level:3},{value:"Map types",id:"map-types",level:2},{value:"Nested map types",id:"nested-map-types",level:2},{value:"Structs / Interfaces",id:"structs--interfaces",level:2},{value:"Field names",id:"field-names",level:3},{value:"Default Go => TypeScript",id:"default-go--typescript",level:4},{value:"Idiomatic field names",id:"idiomatic-field-names",level:4},{value:"Optional and nullable fields",id:"optional-and-nullable-fields",level:3},{value:"Hiding values from the client",id:"hiding-values-from-the-client",level:3},{value:"Union Types",id:"union-types",level:3},{value:"Scalars",id:"scalars-1",level:4},{value:"Structs",id:"structs-2",level:4}],c={toc:o},u="wrapper";function m(e){let{components:t,...n}=e;return(0,r.kt)(u,(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"value-objects"},"Value Objects"),(0,r.kt)("p",null,"Typically value objects will be serialized / marshalled as JSON. Please refer to this documentation:"),(0,r.kt)("p",null,(0,r.kt)("a",{parentName:"p",href:"https://pkg.go.dev/encoding/json#Marshal"},"https://pkg.go.dev/encoding/json#Marshal")),(0,r.kt)("admonition",{type:"note"},(0,r.kt)("p",{parentName:"admonition"},"This is just a few basic examples, that show the basics of mapping Go types to idiomatic TypeScript types.")),(0,r.kt)("h2",{id:"scalar-types"},"Scalar types"),(0,r.kt)("h3",{id:"supported-in-go-and-typescript"},"Supported in Go and TypeScript"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Go"),(0,r.kt)("th",{parentName:"tr",align:null},"TypeScript"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"string"),(0,r.kt)("td",{parentName:"tr",align:null},"string")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"bool"),(0,r.kt)("td",{parentName:"tr",align:null},"boolean")))),(0,r.kt)("h3",{id:"numerics--numbers"},"Numerics / numbers"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Go"),(0,r.kt)("th",{parentName:"tr",align:null},"TypeScript"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"int, int8, int16, float32, float64 ..."),(0,r.kt)("td",{parentName:"tr",align:null},"number")))),(0,r.kt)("h3",{id:"type-aliases"},"Type Aliases"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type Greeting string\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Greeting = string;\n")),(0,r.kt)("h2",{id:"enumerations"},"Enumerations"),(0,r.kt)("p",null,"Go does not support enumerations, but ",(0,r.kt)("inlineCode",{parentName:"p"},"gotsrpc")," will translate constants to TypeScripts enums:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Pet string\n\nconst (\n Cat Pet = "cat"\n Dog Pet = "dog"\n Fish Pet = "fish"\n)\n\ntype SeatCount int\n\nconst (\n TwoSeats SeatCount = 2\n FiveSeats SeatCount = 5\n SevenSeats SeatCount = 7\n)\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},'export enum Pet {\n Cat = "cat",\n Dog = "dog",\n Fish = "fish",\n}\n\nexport enum SeatCount {\n FiveSeats = 5,\n SevenSeats = 7,\n TwoSeats = 2,\n}\n')),(0,r.kt)("h2",{id:"slices"},"Slices"),(0,r.kt)("p",null,"Slices are nilable in Go, thus they can be null in TypeScript. They translate to ",(0,r.kt)("inlineCode",{parentName:"p"},"Array|null")," in TypeScript."),(0,r.kt)("h3",{id:"scalar-types-1"},"Scalar types"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[]string\n[]int\n// other numeric types\n[]bool\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null;\nArray | null;\n// all numeric types are numbers\nArray | null;\n")),(0,r.kt)("h3",{id:"other-slice-type-examples"},"Other slice type examples"),(0,r.kt)("h4",{id:"structs"},"Structs"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[]Car\n[]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null;\nArray | null;\n")),(0,r.kt)("h4",{id:"nested-slices"},"Nested slices"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"[][]string\n[][]int\n// ...\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Array | null> | null;\nArray | null> | null;\n// ...\n")),(0,r.kt)("h2",{id:"maps--records"},"Maps / Records"),(0,r.kt)("p",null,"Like slices Go maps are nilable. They translate to ",(0,r.kt)("inlineCode",{parentName:"p"},"Record|null")," in TypeScript."),(0,r.kt)("h3",{id:"scalars"},"Scalars"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string]string\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null;\n")),(0,r.kt)("h3",{id:"structs-1"},"Structs"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null;\n")),(0,r.kt)("h3",{id:"slices-1"},"Slices"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"map[string][]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"Record | null> | null;\n")),(0,r.kt)("h2",{id:"map-types"},"Map types"),(0,r.kt)("p",null,"Go and TypeScript support map / Record types:"),(0,r.kt)("admonition",{type:"tip"},(0,r.kt)("p",{parentName:"admonition"},"Scalar types / type aliases are of particular value when using maps, because they can add strong semantics:")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type CarDirectory map[ProductID]*Car\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type CarDirectory = Record | null;\n")),(0,r.kt)("h2",{id:"nested-map-types"},"Nested map types"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type BrandID string\ntype BrandCarDirectory map[BrandID]map[ProductID]*Car\n// or\ntype BrandCarDirectory map[BrandID]CarDirectory\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type BrandID = string;\ntype BrandCarDirectory = Record<\n BrandID,\n Record | null\n> | null;\n// or\ntype BrandCarDirectory = Record | null;\n")),(0,r.kt)("h2",{id:"structs--interfaces"},"Structs / Interfaces"),(0,r.kt)("p",null,"Arbitrary Types can be composed in structs."),(0,r.kt)("h3",{id:"field-names"},"Field names"),(0,r.kt)("p",null,"Naming conventions are different between Go and TypeScript. In order to bridge the gap between Go and TypeScript Go struct fields can be ",(0,r.kt)("a",{parentName:"p",href:"https://pkg.go.dev/encoding/json#Marshal"},"annotated with tags"),". In this way idiomatic naming of fields can be can be provided for both languages and the translation will be automatic."),(0,r.kt)("h4",{id:"default-go--typescript"},"Default Go => TypeScript"),(0,r.kt)("p",null,"Without json tags TypeScript field names will be like in Go, which is not idiomatic for TypeScript."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},"type Car struct {\n GoCase string\n CamelCase string\n SnakeCase string\n}\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"interface Car {\n GoCase:string;\n CamelCase:string;\n SnakeCase:string;\n}\n")),(0,r.kt)("h4",{id:"idiomatic-field-names"},"Idiomatic field names"),(0,r.kt)("p",null,"Json tags allow controlling the name in TypeScript."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Car struct {\n CamelCase string `json:"camelCase"`\n SnakeCase string `json:"snake_case"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"interface Car {\n camelCase:string;\n snake_case:string;\n}\n")),(0,r.kt)("h3",{id:"optional-and-nullable-fields"},"Optional and nullable fields"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Basic struct {\n Value string `json:"value"`\n OptionalValue string `json:"optionalValue,omitempty"`\n NullableValue *string `json:"nullableValue"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Basic interface {\n value:string;\n optionalValue?:string;\n nullableValue:string|null;\n}\n")),(0,r.kt)("h3",{id:"hiding-values-from-the-client"},"Hiding values from the client"),(0,r.kt)("p",null,"The Go json tag ",(0,r.kt)("inlineCode",{parentName:"p"},'`json:"-"`')," on a struct allows it to:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"hide fields from clients"),(0,r.kt)("li",{parentName:"ul"},"prevents clients from setting them in JSON Unmarshalling")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type Basic struct {\n Value string `json:"value"`\n Secret string `json:"-"`\n}\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"type Basic interface {\n value:string;\n}\n")),(0,r.kt)("h3",{id:"union-types"},"Union Types"),(0,r.kt)("p",null,"When static types seem to be in the way"),(0,r.kt)("h4",{id:"scalars-1"},"Scalars"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type (\n Species struct {\n LandAnimals *LandAnimals `json:"landAnimals,omitempty" gotsrpc:"union"`\n WaterAnimals *WaterAnimals `json:"waterAnimals,omitempty" gotsrpc:"union"`\n }\n LandAnimals string\n WaterAnimals string\n )\n \n const (\n Cat LandAnimals = "cat"\n Dog LandAnimals = "dog"\n )\n \n const (\n Catfish WaterAnimals = "catfish"\n Dogfish WaterAnimals = "dogfish"\n )\n)\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},'export enum WaterAnimals {\n Catfish = "catfish",\n Dogfish = "dogfish",\n}\n\nexport enum LandAnimals {\n Cat = "cat",\n Dog = "dog",\n}\n\nexport const Species = { ...github_com_foomo_gotsrpc_playground_server_services_wof.LandAnimals, ...github_com_foomo_gotsrpc_playground_server_services_wof.WaterAnimals }\nexport type Species = github_com_foomo_gotsrpc_playground_server_services_wof.LandAnimals | github_com_foomo_gotsrpc_playground_server_services_wof.WaterAnimals\n')),(0,r.kt)("h4",{id:"structs-2"},"Structs"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-go",metastring:'title="Go"',title:'"Go"'},'type (\n Trip struct {\n Kind string `json:"kind" gotsrpc:"type:\'Trip\'"`\n Destination string `json:"destination"`\n }\n Car struct {\n Kind string `json:"kind" gotsrpc:"type:\'Car\'"`\n Model string `json:"model"`\n }\n Pet struct {\n Kind string `json:"kind" gotsrpc:"type:\'Pet\'"`\n Name string `json:"name"`\n }\n Price struct {\n Trip *Trip `json:"trip,omitempty" gotsrpc:"union"`\n Car *Car `json:"car,omitempty" gotsrpc:"union"`\n Pet *Pet `json:"pet,omitempty" gotsrpc:"union"`\n }\n)\n')),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript",metastring:'title="TypeScript"',title:'"TypeScript"'},"export interface Trip {\n kind:'Trip';\n destination:string;\n}\n\nexport interface Car {\n kind:'Car';\n model:string;\n}\n\nexport interface Pet {\n kind:'Pet';\n name:string;\n}\n\nexport type Price = github_com_foomo_gotsrpc_playground_server_services_wof.Trip | github_com_foomo_gotsrpc_playground_server_services_wof.Car | github_com_foomo_gotsrpc_playground_server_services_wof.Pet | undefined\n")))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.2b2cf787.js b/assets/js/runtime~main.9b95f4c1.js similarity index 98% rename from assets/js/runtime~main.2b2cf787.js rename to assets/js/runtime~main.9b95f4c1.js index 244ea12..876ee4b 100644 --- a/assets/js/runtime~main.2b2cf787.js +++ b/assets/js/runtime~main.9b95f4c1.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,c,f,b,d={},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var c=t[e]={id:e,loaded:!1,exports:{}};return d[e].call(c.exports,c,c.exports,r),c.loaded=!0,c.exports}r.m=d,e=[],r.O=(a,c,f,b)=>{if(!c){var d=1/0;for(i=0;i=b)&&Object.keys(r.O).every((e=>r.O[e](c[o])))?c.splice(o--,1):(t=!1,b0&&e[i-1][2]>b;i--)e[i]=e[i-1];e[i]=[c,f,b]},r.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return r.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var b=Object.create(null);r.r(b);var d={};a=a||[null,c({}),c([]),c(c)];for(var t=2&f&&e;"object"==typeof t&&!~a.indexOf(t);t=c(t))Object.getOwnPropertyNames(t).forEach((a=>d[a]=()=>e[a]));return d.default=()=>e,r.d(b,d),b},r.d=(e,a)=>{for(var c in a)r.o(a,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((a,c)=>(r.f[c](e,a),a)),[])),r.u=e=>"assets/js/"+({41:"075f70f6",53:"935f2afb",259:"99a66f7b",405:"8047a11d",429:"a081292a",533:"b2b675dd",701:"c9619828",801:"2b6f3ca6",874:"e7bf32fe",899:"b8302cf9",916:"6b76192b",1135:"e1c24b22",1181:"98a11806",1186:"e6e8ac82",1213:"559c04ef",1284:"90c7e6e2",1364:"23b2474b",1435:"26ea2a44",1477:"b2f554cd",1647:"c7c8c3b9",1654:"61e4c616",1658:"0fc9ee27",1713:"a7023ddc",1880:"bee3f77a",1911:"1aa4b20d",1937:"dc1592f9",2009:"6585d5e4",2078:"d1323eba",2115:"da5526be",2233:"3352bb21",2289:"a2a43668",2346:"53501021",2364:"f12ae7d6",2416:"395ebfc6",2423:"87b8e9c4",2471:"866d8221",2535:"814f3328",2648:"0606a637",2672:"ac94ec9c",2833:"9a50dba7",2880:"ba52226f",2911:"b93844a0",3085:"1f391b9e",3089:"a6aa9e1f",3098:"0cb03d1c",3174:"020a1d6e",3177:"92fae144",3181:"684a419f",3223:"4c37729a",3237:"1df93b7f",3306:"852c116a",3393:"f258ed81",3411:"78a933e5",3429:"bee0439a",3608:"9e4087bc",3626:"8139c962",3751:"3720c009",3771:"10f38619",3795:"eff90d52",3821:"bd6abed1",3866:"c6d1405e",3899:"99bb4438",3925:"1ca91aca",3964:"aedc5931",3969:"c1acf0e3",4013:"01a85c17",4056:"de6d74a4",4064:"9ad7f93b",4078:"4bb443f0",4080:"f9b88137",4089:"cc5765fc",4121:"55960ee5",4122:"ce400a0c",4168:"588f630f",4170:"beea6c26",4234:"8d92c451",4491:"c6f71f2b",4574:"36213d62",4622:"29f10043",4636:"d694a256",4742:"f0d1e73f",4761:"02493ab9",4794:"a2518eb5",4859:"f7d870b9",4894:"5d6cc085",4963:"15d070c3",5012:"73d13a5e",5222:"fff13b15",5260:"45c436a9",5297:"d341be2c",5331:"53c6067e",5391:"acdb879b",5398:"d9c065e5",5408:"e25ea6ac",5477:"fe08baec",5500:"7071e909",5719:"241a966b",5791:"3338c0e0",5817:"e35f371e",5839:"7fdf1619",5867:"feda6906",5900:"35b210c0",5902:"f1808d3f",5949:"844b6658",6009:"cd2041f2",6073:"72cf7f21",6083:"146489e7",6093:"c1822dcf",6103:"ccc49370",6222:"4ec6c0ec",6227:"5039a037",6284:"00b62936",6442:"dcbaab97",6447:"cce51cf2",6465:"c3ad09c3",6516:"c5cdc278",6579:"2cb19d2e",6582:"c2b2df4f",6618:"a20900f1",6659:"2ce92a49",6660:"04056cce",6788:"050cf89e",6840:"5f154b3e",6900:"924ef73d",7027:"70617f54",7094:"315bfb0c",7269:"e08adee6",7355:"dd79439c",7365:"60284798",7369:"6ae7c37b",7478:"06e8b2de",7533:"3b233ea0",7566:"0911540a",7583:"4709a4ae",7602:"66aa330a",7609:"6b9bd0c6",7659:"fc3deafd",7690:"2c1548e1",7696:"2b793916",7748:"7a6b4665",7779:"2e75142e",7785:"3d3976a7",7828:"600efa5e",7918:"17896441",7920:"1a4e3797",7958:"4d194efc",7967:"565442c9",8111:"d41e2ef6",8180:"fd894448",8289:"2baf519b",8392:"15b89b76",8423:"12623ccc",8462:"e8b8784f",8495:"a8a1ab13",8503:"8077e178",8556:"9b9e93c8",8610:"6875c492",8666:"b0751d67",8732:"4f538471",8735:"37e97a4e",8988:"388fbbd1",9069:"0571ecea",9116:"e62c5aa0",9142:"2e7a3344",9196:"f768d962",9493:"96e76de9",9494:"9cb50806",9514:"1be78505",9543:"1b3e71b9",9621:"139169e6",9678:"45748f8b",9802:"f265cf48",9819:"ca892649",9822:"c99de435",9851:"487ae42e",9924:"df203c0f",9925:"10e1d9b6"}[e]||e)+"."+{41:"dddfaba0",53:"f34fe3ee",259:"28e339a1",405:"26a767f7",429:"24413197",533:"dd3f0d7d",701:"caa7d66b",801:"290e168e",874:"ef06b646",899:"324b00c5",916:"33542e6e",1135:"0100bd14",1181:"d11a410f",1186:"a395db48",1213:"da6e3794",1284:"80970463",1364:"74116be6",1426:"98500830",1435:"e95e0c70",1477:"5d9ec660",1647:"d174a7b6",1654:"74302057",1658:"c7976dbb",1713:"430c7bbe",1880:"68d12f25",1911:"010fa25c",1937:"37f115f0",2009:"06c96613",2078:"a7701851",2115:"f3337cd2",2233:"ee0b4e9d",2289:"fe7bad2c",2346:"82437da3",2364:"d96ac6d0",2416:"0d09397a",2423:"408c1281",2471:"741b9dd6",2529:"e362d256",2535:"2c5b62f5",2648:"55deea56",2672:"8755c398",2833:"5dad1075",2880:"6170d35a",2911:"21563cdd",3085:"7a13fede",3089:"2bb6e996",3098:"6615b3ee",3140:"fb5e5ddd",3174:"70516b8a",3177:"5b70eae3",3181:"7233aa4c",3223:"e3ee5ac1",3237:"efd378a3",3306:"0951dbf2",3393:"6e012be0",3411:"d3c8ab10",3429:"efec4490",3608:"5f5681cd",3626:"557ae927",3751:"05feef7e",3771:"603c836c",3795:"acc48315",3821:"72015f86",3866:"bfffca9e",3899:"6daa5630",3925:"5443e153",3964:"bf6a6eeb",3969:"0bb5262c",4013:"1f2f9b25",4056:"8c54c25f",4064:"835a190b",4078:"8d5d21ab",4080:"731a3947",4089:"73f1edea",4121:"d5a4690b",4122:"1bd3c2a5",4168:"8bec59f8",4170:"43b3b1a1",4234:"979a2598",4491:"97ac7eee",4574:"e1da1ba7",4622:"2832aa9e",4636:"70f85702",4742:"eb9c0c6a",4761:"f7eeecef",4794:"a6057c96",4859:"8d0e2bc1",4894:"1b3a40c0",4963:"7ae335ea",4972:"05cb59b7",5012:"2a0c44ae",5222:"5b88222c",5260:"fd7750d8",5297:"63057038",5331:"8540a24f",5391:"c39cdb97",5398:"26ce72c0",5408:"4b3be37b",5477:"30e75d02",5500:"a39f0aa5",5719:"90b4b489",5791:"46001c6b",5817:"5721a906",5839:"f5a4f091",5867:"8bae4a05",5900:"66826127",5902:"fad01d28",5949:"08381b29",6009:"a32f26d2",6073:"5526eefa",6083:"77357661",6093:"e6457e48",6103:"2473a265",6222:"344860e9",6227:"3f9754dd",6284:"071d1a82",6442:"3a93e492",6447:"e20bf887",6465:"1902a1c5",6516:"86149bcf",6579:"dfe6c86c",6582:"23224d1c",6618:"d8e2e996",6659:"b56e376c",6660:"d9bd64d5",6788:"a85c2f8e",6840:"6545024c",6900:"3a65bea3",6945:"e0f570b6",7027:"c9e83562",7094:"8e127d54",7269:"c84a0e67",7355:"230597f3",7365:"57746b5e",7369:"4ac54106",7478:"5c2e11d2",7533:"ea1d2eec",7566:"bd6a917c",7583:"c931b4ac",7602:"891726a7",7609:"4524307c",7659:"d6034df3",7690:"c22bce88",7696:"58df9b74",7748:"dff763ce",7779:"01971e13",7785:"4f7d0217",7828:"dfced221",7918:"01476ee6",7920:"bc9f0a32",7958:"587909ff",7967:"b56702e7",8111:"e9bfe4cc",8180:"0316ac82",8289:"c9b9d080",8392:"e7b543df",8423:"78655d8b",8462:"70fa53be",8495:"a8ded8bc",8503:"4dc4cd76",8556:"0b2b782d",8576:"7d449cdb",8610:"ef4a6681",8666:"bfc2a1c4",8732:"22c24560",8735:"b8d74e51",8894:"e83b22f8",8988:"20590cef",9069:"fb1ba2e6",9116:"b8628b61",9142:"48ef0b32",9196:"bbca3f06",9493:"82190d76",9494:"0089eac9",9514:"67a46d07",9543:"790e2d25",9621:"9eb52d15",9678:"5c853a82",9802:"76ce2d7f",9819:"bb426d87",9822:"a453a16c",9851:"a0943f9c",9924:"838ca7f0",9925:"b882d905"}[e]+".js",r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},b="foomo:",r.l=(e,a,c,d)=>{if(f[e])f[e].push(a);else{var t,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{t.onerror=t.onload=null,clearTimeout(s);var b=f[e];if(delete f[e],t.parentNode&&t.parentNode.removeChild(t),b&&b.forEach((e=>e(c))),a)return a(c)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=u.bind(null,t.onerror),t.onload=u.bind(null,t.onload),o&&document.head.appendChild(t)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.p="/",r.gca=function(e){return e={17896441:"7918",53501021:"2346",60284798:"7365","075f70f6":"41","935f2afb":"53","99a66f7b":"259","8047a11d":"405",a081292a:"429",b2b675dd:"533",c9619828:"701","2b6f3ca6":"801",e7bf32fe:"874",b8302cf9:"899","6b76192b":"916",e1c24b22:"1135","98a11806":"1181",e6e8ac82:"1186","559c04ef":"1213","90c7e6e2":"1284","23b2474b":"1364","26ea2a44":"1435",b2f554cd:"1477",c7c8c3b9:"1647","61e4c616":"1654","0fc9ee27":"1658",a7023ddc:"1713",bee3f77a:"1880","1aa4b20d":"1911",dc1592f9:"1937","6585d5e4":"2009",d1323eba:"2078",da5526be:"2115","3352bb21":"2233",a2a43668:"2289",f12ae7d6:"2364","395ebfc6":"2416","87b8e9c4":"2423","866d8221":"2471","814f3328":"2535","0606a637":"2648",ac94ec9c:"2672","9a50dba7":"2833",ba52226f:"2880",b93844a0:"2911","1f391b9e":"3085",a6aa9e1f:"3089","0cb03d1c":"3098","020a1d6e":"3174","92fae144":"3177","684a419f":"3181","4c37729a":"3223","1df93b7f":"3237","852c116a":"3306",f258ed81:"3393","78a933e5":"3411",bee0439a:"3429","9e4087bc":"3608","8139c962":"3626","3720c009":"3751","10f38619":"3771",eff90d52:"3795",bd6abed1:"3821",c6d1405e:"3866","99bb4438":"3899","1ca91aca":"3925",aedc5931:"3964",c1acf0e3:"3969","01a85c17":"4013",de6d74a4:"4056","9ad7f93b":"4064","4bb443f0":"4078",f9b88137:"4080",cc5765fc:"4089","55960ee5":"4121",ce400a0c:"4122","588f630f":"4168",beea6c26:"4170","8d92c451":"4234",c6f71f2b:"4491","36213d62":"4574","29f10043":"4622",d694a256:"4636",f0d1e73f:"4742","02493ab9":"4761",a2518eb5:"4794",f7d870b9:"4859","5d6cc085":"4894","15d070c3":"4963","73d13a5e":"5012",fff13b15:"5222","45c436a9":"5260",d341be2c:"5297","53c6067e":"5331",acdb879b:"5391",d9c065e5:"5398",e25ea6ac:"5408",fe08baec:"5477","7071e909":"5500","241a966b":"5719","3338c0e0":"5791",e35f371e:"5817","7fdf1619":"5839",feda6906:"5867","35b210c0":"5900",f1808d3f:"5902","844b6658":"5949",cd2041f2:"6009","72cf7f21":"6073","146489e7":"6083",c1822dcf:"6093",ccc49370:"6103","4ec6c0ec":"6222","5039a037":"6227","00b62936":"6284",dcbaab97:"6442",cce51cf2:"6447",c3ad09c3:"6465",c5cdc278:"6516","2cb19d2e":"6579",c2b2df4f:"6582",a20900f1:"6618","2ce92a49":"6659","04056cce":"6660","050cf89e":"6788","5f154b3e":"6840","924ef73d":"6900","70617f54":"7027","315bfb0c":"7094",e08adee6:"7269",dd79439c:"7355","6ae7c37b":"7369","06e8b2de":"7478","3b233ea0":"7533","0911540a":"7566","4709a4ae":"7583","66aa330a":"7602","6b9bd0c6":"7609",fc3deafd:"7659","2c1548e1":"7690","2b793916":"7696","7a6b4665":"7748","2e75142e":"7779","3d3976a7":"7785","600efa5e":"7828","1a4e3797":"7920","4d194efc":"7958","565442c9":"7967",d41e2ef6:"8111",fd894448:"8180","2baf519b":"8289","15b89b76":"8392","12623ccc":"8423",e8b8784f:"8462",a8a1ab13:"8495","8077e178":"8503","9b9e93c8":"8556","6875c492":"8610",b0751d67:"8666","4f538471":"8732","37e97a4e":"8735","388fbbd1":"8988","0571ecea":"9069",e62c5aa0:"9116","2e7a3344":"9142",f768d962:"9196","96e76de9":"9493","9cb50806":"9494","1be78505":"9514","1b3e71b9":"9543","139169e6":"9621","45748f8b":"9678",f265cf48:"9802",ca892649:"9819",c99de435:"9822","487ae42e":"9851",df203c0f:"9924","10e1d9b6":"9925"}[e]||e,r.p+r.u(e)},(()=>{var e={1303:0,532:0};r.f.j=(a,c)=>{var f=r.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1303|532)$/.test(a))e[a]=0;else{var b=new Promise(((c,b)=>f=e[a]=[c,b]));c.push(f[2]=b);var d=r.p+r.u(a),t=new Error;r.l(d,(c=>{if(r.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var b=c&&("load"===c.type?"missing":c.type),d=c&&c.target&&c.target.src;t.message="Loading chunk "+a+" failed.\n("+b+": "+d+")",t.name="ChunkLoadError",t.type=b,t.request=d,f[1](t)}}),"chunk-"+a,a)}},r.O.j=a=>0===e[a];var a=(a,c)=>{var f,b,d=c[0],t=c[1],o=c[2],n=0;if(d.some((a=>0!==e[a]))){for(f in t)r.o(t,f)&&(r.m[f]=t[f]);if(o)var i=o(r)}for(a&&a(c);n{"use strict";var e,a,c,f,b,d={},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var c=t[e]={id:e,loaded:!1,exports:{}};return d[e].call(c.exports,c,c.exports,r),c.loaded=!0,c.exports}r.m=d,e=[],r.O=(a,c,f,b)=>{if(!c){var d=1/0;for(i=0;i=b)&&Object.keys(r.O).every((e=>r.O[e](c[o])))?c.splice(o--,1):(t=!1,b0&&e[i-1][2]>b;i--)e[i]=e[i-1];e[i]=[c,f,b]},r.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return r.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var b=Object.create(null);r.r(b);var d={};a=a||[null,c({}),c([]),c(c)];for(var t=2&f&&e;"object"==typeof t&&!~a.indexOf(t);t=c(t))Object.getOwnPropertyNames(t).forEach((a=>d[a]=()=>e[a]));return d.default=()=>e,r.d(b,d),b},r.d=(e,a)=>{for(var c in a)r.o(a,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((a,c)=>(r.f[c](e,a),a)),[])),r.u=e=>"assets/js/"+({41:"075f70f6",53:"935f2afb",259:"99a66f7b",405:"8047a11d",429:"a081292a",533:"b2b675dd",701:"c9619828",801:"2b6f3ca6",874:"e7bf32fe",899:"b8302cf9",916:"6b76192b",1135:"e1c24b22",1181:"98a11806",1186:"e6e8ac82",1213:"559c04ef",1284:"90c7e6e2",1364:"23b2474b",1435:"26ea2a44",1477:"b2f554cd",1647:"c7c8c3b9",1654:"61e4c616",1658:"0fc9ee27",1713:"a7023ddc",1880:"bee3f77a",1911:"1aa4b20d",1937:"dc1592f9",2009:"6585d5e4",2078:"d1323eba",2115:"da5526be",2233:"3352bb21",2289:"a2a43668",2346:"53501021",2364:"f12ae7d6",2416:"395ebfc6",2423:"87b8e9c4",2471:"866d8221",2535:"814f3328",2648:"0606a637",2672:"ac94ec9c",2833:"9a50dba7",2880:"ba52226f",2911:"b93844a0",3085:"1f391b9e",3089:"a6aa9e1f",3098:"0cb03d1c",3174:"020a1d6e",3177:"92fae144",3181:"684a419f",3223:"4c37729a",3237:"1df93b7f",3306:"852c116a",3393:"f258ed81",3411:"78a933e5",3429:"bee0439a",3608:"9e4087bc",3626:"8139c962",3751:"3720c009",3771:"10f38619",3795:"eff90d52",3821:"bd6abed1",3866:"c6d1405e",3899:"99bb4438",3925:"1ca91aca",3964:"aedc5931",3969:"c1acf0e3",4013:"01a85c17",4056:"de6d74a4",4064:"9ad7f93b",4078:"4bb443f0",4080:"f9b88137",4089:"cc5765fc",4121:"55960ee5",4122:"ce400a0c",4168:"588f630f",4170:"beea6c26",4234:"8d92c451",4491:"c6f71f2b",4574:"36213d62",4622:"29f10043",4636:"d694a256",4742:"f0d1e73f",4761:"02493ab9",4794:"a2518eb5",4859:"f7d870b9",4894:"5d6cc085",4963:"15d070c3",5012:"73d13a5e",5222:"fff13b15",5260:"45c436a9",5297:"d341be2c",5331:"53c6067e",5391:"acdb879b",5398:"d9c065e5",5408:"e25ea6ac",5477:"fe08baec",5500:"7071e909",5719:"241a966b",5791:"3338c0e0",5817:"e35f371e",5839:"7fdf1619",5867:"feda6906",5900:"35b210c0",5902:"f1808d3f",5949:"844b6658",6009:"cd2041f2",6073:"72cf7f21",6083:"146489e7",6093:"c1822dcf",6103:"ccc49370",6222:"4ec6c0ec",6227:"5039a037",6284:"00b62936",6442:"dcbaab97",6447:"cce51cf2",6465:"c3ad09c3",6516:"c5cdc278",6579:"2cb19d2e",6582:"c2b2df4f",6618:"a20900f1",6659:"2ce92a49",6660:"04056cce",6788:"050cf89e",6840:"5f154b3e",6900:"924ef73d",7027:"70617f54",7094:"315bfb0c",7269:"e08adee6",7355:"dd79439c",7365:"60284798",7369:"6ae7c37b",7478:"06e8b2de",7533:"3b233ea0",7566:"0911540a",7583:"4709a4ae",7602:"66aa330a",7609:"6b9bd0c6",7659:"fc3deafd",7690:"2c1548e1",7696:"2b793916",7748:"7a6b4665",7779:"2e75142e",7785:"3d3976a7",7828:"600efa5e",7918:"17896441",7920:"1a4e3797",7958:"4d194efc",7967:"565442c9",8111:"d41e2ef6",8180:"fd894448",8289:"2baf519b",8392:"15b89b76",8423:"12623ccc",8462:"e8b8784f",8495:"a8a1ab13",8503:"8077e178",8556:"9b9e93c8",8610:"6875c492",8666:"b0751d67",8732:"4f538471",8735:"37e97a4e",8988:"388fbbd1",9069:"0571ecea",9116:"e62c5aa0",9142:"2e7a3344",9196:"f768d962",9493:"96e76de9",9494:"9cb50806",9514:"1be78505",9543:"1b3e71b9",9621:"139169e6",9678:"45748f8b",9802:"f265cf48",9819:"ca892649",9822:"c99de435",9851:"487ae42e",9924:"df203c0f",9925:"10e1d9b6"}[e]||e)+"."+{41:"dddfaba0",53:"32db5421",259:"28e339a1",405:"26a767f7",429:"24413197",533:"dd3f0d7d",701:"caa7d66b",801:"290e168e",874:"ef06b646",899:"324b00c5",916:"33542e6e",1135:"0100bd14",1181:"d11a410f",1186:"a395db48",1213:"da6e3794",1284:"80970463",1364:"74116be6",1426:"98500830",1435:"e95e0c70",1477:"5d9ec660",1647:"d174a7b6",1654:"74302057",1658:"c7976dbb",1713:"430c7bbe",1880:"68d12f25",1911:"010fa25c",1937:"37f115f0",2009:"06c96613",2078:"a7701851",2115:"f3337cd2",2233:"ee0b4e9d",2289:"fe7bad2c",2346:"82437da3",2364:"d96ac6d0",2416:"0d09397a",2423:"408c1281",2471:"741b9dd6",2529:"e362d256",2535:"2c5b62f5",2648:"55deea56",2672:"8755c398",2833:"5dad1075",2880:"6170d35a",2911:"21563cdd",3085:"7a13fede",3089:"2bb6e996",3098:"6615b3ee",3140:"fb5e5ddd",3174:"70516b8a",3177:"5b70eae3",3181:"7233aa4c",3223:"e3ee5ac1",3237:"efd378a3",3306:"0951dbf2",3393:"6e012be0",3411:"d3c8ab10",3429:"efec4490",3608:"5f5681cd",3626:"557ae927",3751:"05feef7e",3771:"603c836c",3795:"acc48315",3821:"72015f86",3866:"bfffca9e",3899:"6daa5630",3925:"5443e153",3964:"fbb9b81b",3969:"0bb5262c",4013:"1f2f9b25",4056:"8c54c25f",4064:"835a190b",4078:"8d5d21ab",4080:"731a3947",4089:"73f1edea",4121:"d5a4690b",4122:"1bd3c2a5",4168:"8bec59f8",4170:"43b3b1a1",4234:"979a2598",4491:"97ac7eee",4574:"e1da1ba7",4622:"2832aa9e",4636:"70f85702",4742:"eb9c0c6a",4761:"f7eeecef",4794:"a6057c96",4859:"8d0e2bc1",4894:"1b3a40c0",4963:"7ae335ea",4972:"05cb59b7",5012:"2a0c44ae",5222:"5b88222c",5260:"fd7750d8",5297:"63057038",5331:"8540a24f",5391:"c39cdb97",5398:"26ce72c0",5408:"4b3be37b",5477:"30e75d02",5500:"a39f0aa5",5719:"62f942f6",5791:"46001c6b",5817:"5721a906",5839:"f5a4f091",5867:"8bae4a05",5900:"66826127",5902:"fad01d28",5949:"08381b29",6009:"a32f26d2",6073:"5526eefa",6083:"77357661",6093:"e6457e48",6103:"2473a265",6222:"344860e9",6227:"3f9754dd",6284:"071d1a82",6442:"3a93e492",6447:"e20bf887",6465:"1902a1c5",6516:"86149bcf",6579:"dfe6c86c",6582:"23224d1c",6618:"d8e2e996",6659:"b56e376c",6660:"d9bd64d5",6788:"a85c2f8e",6840:"6545024c",6900:"3a65bea3",6945:"e0f570b6",7027:"c9e83562",7094:"8e127d54",7269:"c84a0e67",7355:"230597f3",7365:"57746b5e",7369:"4ac54106",7478:"5c2e11d2",7533:"ea1d2eec",7566:"bd6a917c",7583:"c931b4ac",7602:"891726a7",7609:"4524307c",7659:"d6034df3",7690:"c22bce88",7696:"58df9b74",7748:"dff763ce",7779:"01971e13",7785:"4f7d0217",7828:"dfced221",7918:"01476ee6",7920:"bc9f0a32",7958:"587909ff",7967:"b56702e7",8111:"e9bfe4cc",8180:"0316ac82",8289:"c9b9d080",8392:"e7b543df",8423:"78655d8b",8462:"70fa53be",8495:"a8ded8bc",8503:"4dc4cd76",8556:"0b2b782d",8576:"7d449cdb",8610:"ef4a6681",8666:"bfc2a1c4",8732:"22c24560",8735:"b8d74e51",8894:"e83b22f8",8988:"20590cef",9069:"fb1ba2e6",9116:"b8628b61",9142:"48ef0b32",9196:"bbca3f06",9493:"82190d76",9494:"0089eac9",9514:"67a46d07",9543:"790e2d25",9621:"9eb52d15",9678:"5c853a82",9802:"76ce2d7f",9819:"bb426d87",9822:"a453a16c",9851:"a0943f9c",9924:"838ca7f0",9925:"b882d905"}[e]+".js",r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},b="foomo:",r.l=(e,a,c,d)=>{if(f[e])f[e].push(a);else{var t,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{t.onerror=t.onload=null,clearTimeout(s);var b=f[e];if(delete f[e],t.parentNode&&t.parentNode.removeChild(t),b&&b.forEach((e=>e(c))),a)return a(c)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=u.bind(null,t.onerror),t.onload=u.bind(null,t.onload),o&&document.head.appendChild(t)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.p="/",r.gca=function(e){return e={17896441:"7918",53501021:"2346",60284798:"7365","075f70f6":"41","935f2afb":"53","99a66f7b":"259","8047a11d":"405",a081292a:"429",b2b675dd:"533",c9619828:"701","2b6f3ca6":"801",e7bf32fe:"874",b8302cf9:"899","6b76192b":"916",e1c24b22:"1135","98a11806":"1181",e6e8ac82:"1186","559c04ef":"1213","90c7e6e2":"1284","23b2474b":"1364","26ea2a44":"1435",b2f554cd:"1477",c7c8c3b9:"1647","61e4c616":"1654","0fc9ee27":"1658",a7023ddc:"1713",bee3f77a:"1880","1aa4b20d":"1911",dc1592f9:"1937","6585d5e4":"2009",d1323eba:"2078",da5526be:"2115","3352bb21":"2233",a2a43668:"2289",f12ae7d6:"2364","395ebfc6":"2416","87b8e9c4":"2423","866d8221":"2471","814f3328":"2535","0606a637":"2648",ac94ec9c:"2672","9a50dba7":"2833",ba52226f:"2880",b93844a0:"2911","1f391b9e":"3085",a6aa9e1f:"3089","0cb03d1c":"3098","020a1d6e":"3174","92fae144":"3177","684a419f":"3181","4c37729a":"3223","1df93b7f":"3237","852c116a":"3306",f258ed81:"3393","78a933e5":"3411",bee0439a:"3429","9e4087bc":"3608","8139c962":"3626","3720c009":"3751","10f38619":"3771",eff90d52:"3795",bd6abed1:"3821",c6d1405e:"3866","99bb4438":"3899","1ca91aca":"3925",aedc5931:"3964",c1acf0e3:"3969","01a85c17":"4013",de6d74a4:"4056","9ad7f93b":"4064","4bb443f0":"4078",f9b88137:"4080",cc5765fc:"4089","55960ee5":"4121",ce400a0c:"4122","588f630f":"4168",beea6c26:"4170","8d92c451":"4234",c6f71f2b:"4491","36213d62":"4574","29f10043":"4622",d694a256:"4636",f0d1e73f:"4742","02493ab9":"4761",a2518eb5:"4794",f7d870b9:"4859","5d6cc085":"4894","15d070c3":"4963","73d13a5e":"5012",fff13b15:"5222","45c436a9":"5260",d341be2c:"5297","53c6067e":"5331",acdb879b:"5391",d9c065e5:"5398",e25ea6ac:"5408",fe08baec:"5477","7071e909":"5500","241a966b":"5719","3338c0e0":"5791",e35f371e:"5817","7fdf1619":"5839",feda6906:"5867","35b210c0":"5900",f1808d3f:"5902","844b6658":"5949",cd2041f2:"6009","72cf7f21":"6073","146489e7":"6083",c1822dcf:"6093",ccc49370:"6103","4ec6c0ec":"6222","5039a037":"6227","00b62936":"6284",dcbaab97:"6442",cce51cf2:"6447",c3ad09c3:"6465",c5cdc278:"6516","2cb19d2e":"6579",c2b2df4f:"6582",a20900f1:"6618","2ce92a49":"6659","04056cce":"6660","050cf89e":"6788","5f154b3e":"6840","924ef73d":"6900","70617f54":"7027","315bfb0c":"7094",e08adee6:"7269",dd79439c:"7355","6ae7c37b":"7369","06e8b2de":"7478","3b233ea0":"7533","0911540a":"7566","4709a4ae":"7583","66aa330a":"7602","6b9bd0c6":"7609",fc3deafd:"7659","2c1548e1":"7690","2b793916":"7696","7a6b4665":"7748","2e75142e":"7779","3d3976a7":"7785","600efa5e":"7828","1a4e3797":"7920","4d194efc":"7958","565442c9":"7967",d41e2ef6:"8111",fd894448:"8180","2baf519b":"8289","15b89b76":"8392","12623ccc":"8423",e8b8784f:"8462",a8a1ab13:"8495","8077e178":"8503","9b9e93c8":"8556","6875c492":"8610",b0751d67:"8666","4f538471":"8732","37e97a4e":"8735","388fbbd1":"8988","0571ecea":"9069",e62c5aa0:"9116","2e7a3344":"9142",f768d962:"9196","96e76de9":"9493","9cb50806":"9494","1be78505":"9514","1b3e71b9":"9543","139169e6":"9621","45748f8b":"9678",f265cf48:"9802",ca892649:"9819",c99de435:"9822","487ae42e":"9851",df203c0f:"9924","10e1d9b6":"9925"}[e]||e,r.p+r.u(e)},(()=>{var e={1303:0,532:0};r.f.j=(a,c)=>{var f=r.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1303|532)$/.test(a))e[a]=0;else{var b=new Promise(((c,b)=>f=e[a]=[c,b]));c.push(f[2]=b);var d=r.p+r.u(a),t=new Error;r.l(d,(c=>{if(r.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var b=c&&("load"===c.type?"missing":c.type),d=c&&c.target&&c.target.src;t.message="Loading chunk "+a+" failed.\n("+b+": "+d+")",t.name="ChunkLoadError",t.type=b,t.request=d,f[1](t)}}),"chunk-"+a,a)}},r.O.j=a=>0===e[a];var a=(a,c)=>{var f,b,d=c[0],t=c[1],o=c[2],n=0;if(d.some((a=>0!==e[a]))){for(f in t)r.o(t,f)&&(r.m[f]=t[f]);if(o)var i=o(r)}for(a&&a(c);n