{"id":805,"date":"2014-08-29T12:25:19","date_gmt":"2014-08-29T16:25:19","guid":{"rendered":"https:\/\/blog.splice.com\/?p=805"},"modified":"2024-01-18T14:43:27","modified_gmt":"2024-01-18T19:43:27","slug":"iota-elegant-constants-golang","status":"publish","type":"post","link":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/","title":{"rendered":"iota: Elegant Constants in Golang"},"content":{"rendered":"<p><small style=\"float: right; margin-bottom: 10px;\"><i>Photo Credit: <a href=\"https:\/\/www.flickr.com\/photos\/blaahhi\/\">blaahhi<\/a><\/i><\/small><\/p>\n<p style=\"clear: both;\">Some concepts have names, and sometimes we care about those names, even (or especially) in our code.<\/p>\n<pre><code>const (\n    CCVisa            = \"Visa\"\n    CCMasterCard      = \"MasterCard\"\n    CCAmericanExpress = \"American Express\"\n)\n<\/code><\/pre>\n<p>At other times, we only care to distinguish one thing from the other. There are times when there&#8217;s no inherently meaningful value for a thing. For example, if we&#8217;re storing products in a database table we probably don&#8217;t want to store their category as a string. We don&#8217;t care how the categories are named, and besides, marketing changes the names all the time.<\/p>\n<p>We care only that they&#8217;re distinct from each other.<\/p>\n<pre><code>const (\n    CategoryBooks    = 0\n    CategoryHealth   = 1\n    CategoryClothing = 2\n)\n<\/code><\/pre>\n<p>Instead of 0, 1, and 2 we could have chosen 17, 43, and 61. The values are arbitrary.<\/p>\n<p>Constants are important but they can be hard to reason about and difficult to maintain. In some languages like Ruby developers often just avoid them. In Go, constants have many interesting subtleties that, when used well, can make the code both elegant and maintainable.<\/p>\n<h2 id=\"auto-increment\">Auto Increment<\/h2>\n<p>A handy idiom for this in golang is to use the <code>iota<\/code> identifier, which simplifies constant definitions that use incrementing numbers, giving the categories exactly the same values as above.<\/p>\n<pre><code>const (\n    CategoryBooks = iota \/\/ 0\n    CategoryHealth       \/\/ 1\n    CategoryClothing     \/\/ 2\n)\n<\/code><\/pre>\n<h2 id=\"custom-types\">Custom Types<\/h2>\n<p>Auto-incrementing constants are often combined with a custom type, allowing you to lean on the compiler.<\/p>\n<pre><code>type Stereotype int\n\nconst (\n    TypicalNoob Stereotype = iota \/\/ 0\n    TypicalHipster                \/\/ 1\n    TypicalUnixWizard             \/\/ 2\n    TypicalStartupFounder         \/\/ 3\n)\n<\/code><\/pre>\n<p>If a function is defined to take an <code>int<\/code> as an argument rather than a <code>Stereotype<\/code>, it will blow up at compile-time if you pass it a <code>Stereotype<\/code>:<\/p>\n<pre><code>func CountAllTheThings(i int) string {\n                return fmt.Sprintf(\"there are %d things\", i)\n}\n\nfunc main() {\n    n := TypicalHipster\n    fmt.Println(CountAllTheThings(n))\n}\n\n\/\/ output:\n\/\/ cannot use TypicalHipster (type Stereotype) as type int in argument to CountAllTheThings\n<\/code><\/pre>\n<p>The inverse is also true. Given a function that takes a <code>Stereotype<\/code> as an argument, you can&#8217;t pass it an <code>int<\/code>:<\/p>\n<pre><code>func SoSayethThe(character Stereotype) string {\n    var s string\n    switch character {\n    case TypicalNoob:\n        s = \"I'm a confused ninja rockstar.\"\n    case TypicalHipster:\n        s = \"Everything was better we programmed uphill and barefoot in the snow on the SUTX 5918\"\n    case TypicalUnixWizard:\n        s = \"sudo grep awk sed %!#?!!1!\"\n    case TypicalStartupFounder:\n        s = \"exploit compelling convergence to syndicate geo-targeted solutions\"\n    }\n    return s\n}\n\nfunc main() {\n    i := 2\n    fmt.Println(SoSayethThe(i))\n}\n\n\/\/ output:\n\/\/ cannot use i (type int) as type Stereotype in argument to SoSayethThe\n<\/code><\/pre>\n<p>There&#8217;s a dramatic twist, however. You could pass a number constant, and it would work:<\/p>\n<pre><code>func main() {\n    fmt.Println(SoSayethThe(0))\n}\n\n\/\/ output:\n\/\/ I'm a confused ninja rockstar.\n<\/code><\/pre>\n<p>This is because constants in Go are loosely typed until they are used in a strict context.<\/p>\n<h2 id=\"skipping-values\">Skipping Values<\/h2>\n<p>Imagine that you&#8217;re dealing with consumer audio output. The audio might not have any output whatsoever, or it could be mono, stereo, or surround.<\/p>\n<p>There&#8217;s some underlying logic to defining <em>no output<\/em> as 0, <em>mono<\/em> as 1, and <em>stereo<\/em> as 2, where the value is the number of channels provided.<\/p>\n<p>So what value do you give <em>Dolby 5.1 surround<\/em>?<\/p>\n<p>On the one hand, it&#8217;s 6 channel output, but on the other hand, only 5 of those channels are full bandwidth channels (hence the 5.1 designation &#8211; with the .1 referring to the low-frequency effects channel).<\/p>\n<p>Either way, we don&#8217;t want to simply increment to 3.<\/p>\n<p>We can use underscores to skip past the unwanted values.<\/p>\n<pre><code>type AudioOutput int\n\nconst (\n    OutMute AudioOutput = iota \/\/ 0\n    OutMono                    \/\/ 1\n    OutStereo                  \/\/ 2\n    _\n    _\n    OutSurround                \/\/ 5\n)\n<\/code><\/pre>\n<h2 id=\"expressions\">Expressions<\/h2>\n<p>The <code>iota<\/code> can do more than just increment. Or rather, <code>iota<\/code> always increments, but it can be used in expressions, storing the resulting value in the constant.<\/p>\n<p>Here we&#8217;re creating constants to be used as a bitmask.<\/p>\n<pre><code>type Allergen int\n\nconst (\n    IgEggs Allergen = 1 &lt;&lt; iota \/\/ 1 &lt;&lt; 0 which is 00000001\n    IgChocolate                         \/\/ 1 &lt;&lt; 1 which is 00000010\n    IgNuts                              \/\/ 1 &lt;&lt; 2 which is 00000100\n    IgStrawberries                      \/\/ 1 &lt;&lt; 3 which is 00001000\n    IgShellfish                         \/\/ 1 &lt;&lt; 4 which is 00010000\n)\n<\/code><\/pre>\n<p>This works because when you have only an identifier on a line in a <code>const<\/code> group, it will take the previous expression and reapply it, with the incremented <code>iota<\/code>. In the language of <a href=\"http:\/\/golang.org\/ref\/spec#Iota\">the spec<\/a>, this is called <em>implicit repetition of the last non-empty expression list<\/em>.<\/p>\n<p>If you&#8217;re allergic to eggs, chocolate, and shellfish, and flip those bits to the &#8220;on&#8221; position (mapping the bits right to left), then you get a bit value of <code>00010011<\/code>, which corresponds to 19 in decimal.<\/p>\n<pre><code>fmt.Println(IgEggs | IgChocolate | IgShellfish)\n\n\/\/ output:\n\/\/ 19\n<\/code><\/pre>\n<p>There&#8217;s a great example in <a href=\"https:\/\/golang.org\/doc\/effective_go.html#constants\">Effective Go<\/a> for defining orders of magnitude:<\/p>\n<pre><code>type ByteSize float64\n\nconst (\n    _           = iota                   \/\/ ignore first value by assigning to blank identifier\n    KB ByteSize = 1 &lt;&lt; (10 * iota) \/\/ 1 &lt;&lt; (10*1)\n    MB                                   \/\/ 1 &lt;&lt; (10*2)\n    GB                                   \/\/ 1 &lt;&lt; (10*3)\n    TB                                   \/\/ 1 &lt;&lt; (10*4)\n    PB                                   \/\/ 1 &lt;&lt; (10*5)\n    EB                                   \/\/ 1 &lt;&lt; (10*6)\n    ZB                                   \/\/ 1 &lt;&lt; (10*7)\n    YB                                   \/\/ 1 &lt;&lt; (10*8)\n)\n<\/code><\/pre>\n<p>Today I learned that after zettabyte we get yottabyte. <b>#TIL<\/b><\/p>\n<h2 id=\"but-wait-theres-more\">But Wait, There&#8217;s More<\/h2>\n<p>What happens if you define two constants on the same line?<br>\nWhat is the value of Banana? 2 or 3? And what about Durian?<\/p>\n<pre><code>const (\n    Apple, Banana = iota + 1, iota + 2\n    Cherimoya, Durian\n    Elderberry, Fig\n)\n<\/code><\/pre>\n<p>The <code>iota<\/code> increments on the next line, rather than as soon as it gets referenced.<\/p>\n<pre><code>\n\/\/ Apple: 1\n\/\/ Banana: 2\n\/\/ Cherimoya: 2\n\/\/ Durian: 3\n\/\/ Elderberry: 3\n\/\/ Fig: 4\n<\/code><\/pre>\n<p>Which is messed up, because now you have constants with the same value.<\/p>\n<h2 id=\"so-yeah\">So, Yeah<\/h2>\n<p>There&#8217;s a lot more to be said about constants in Go, and you should probably read Rob Pike&#8217;s <a href=\"http:\/\/blog.golang.org\/constants\">blog post on the subject<\/a> over on the golang blog.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\">Explore royalty-free sounds from leading artists, producers, and sound designers:<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button aligncenter\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/splice.com\/sounds\" target=\"_blank\" rel=\"noreferrer noopener\">Join Splice today<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Some concepts have names, and sometimes we care about those names, even (or especially) in our code&#8230;<\/p>\n","protected":false},"author":2,"featured_media":809,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[61],"tags":[115],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>iota: Elegant Constants in Golang - Blog | Splice<\/title>\n<meta name=\"description\" content=\"Learn how to optimize your use of constants in Golang using iota.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iota: Elegant Constants in Golang - Blog | Splice\" \/>\n<meta property=\"og:description\" content=\"Learn how to optimize your use of constants in Golang using iota.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog | Splice\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Splice\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/spliceofficial\" \/>\n<meta property=\"article:published_time\" content=\"2014-08-29T16:25:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-18T19:43:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Team Splice\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/splice\" \/>\n<meta name=\"twitter:site\" content=\"@splice\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Team Splice\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\"},\"author\":{\"name\":\"Team Splice\",\"@id\":\"https:\/\/splice.com\/blog\/#\/schema\/person\/1264212de6b56a47de705ec3ad103943\"},\"headline\":\"iota: Elegant Constants in Golang\",\"datePublished\":\"2014-08-29T16:25:19+00:00\",\"dateModified\":\"2024-01-18T19:43:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\"},\"wordCount\":622,\"publisher\":{\"@id\":\"https:\/\/splice.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg\",\"keywords\":[\"engineering\"],\"articleSection\":[\"Engineering\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\",\"url\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\",\"name\":\"iota: Elegant Constants in Golang - Blog | Splice\",\"isPartOf\":{\"@id\":\"https:\/\/splice.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg\",\"datePublished\":\"2014-08-29T16:25:19+00:00\",\"dateModified\":\"2024-01-18T19:43:27+00:00\",\"description\":\"Learn how to optimize your use of constants in Golang using iota.\",\"breadcrumb\":{\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage\",\"url\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg\",\"contentUrl\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg\",\"width\":1024,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/splice.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"iota: Elegant Constants in Golang\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/splice.com\/blog\/#website\",\"url\":\"https:\/\/splice.com\/blog\/\",\"name\":\"Splice Blog\",\"description\":\"An inside look at making music\",\"publisher\":{\"@id\":\"https:\/\/splice.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/splice.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/splice.com\/blog\/#organization\",\"name\":\"Splice\",\"alternateName\":\"Splice Sounds\",\"url\":\"https:\/\/splice.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/splice.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2023\/09\/Splice-logo-black-background.png\",\"contentUrl\":\"https:\/\/splice.com\/blog\/wp-content\/uploads\/2023\/09\/Splice-logo-black-background.png\",\"width\":2928,\"height\":1540,\"caption\":\"Splice\"},\"image\":{\"@id\":\"https:\/\/splice.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Splice\",\"https:\/\/x.com\/splice\",\"https:\/\/www.instagram.com\/splice\/\",\"https:\/\/www.youtube.com\/@splice\",\"https:\/\/discord.com\/invite\/splice\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/splice.com\/blog\/#\/schema\/person\/1264212de6b56a47de705ec3ad103943\",\"name\":\"Team Splice\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/splice.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4428b1733406dca9c238897202320bb3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4428b1733406dca9c238897202320bb3?s=96&d=mm&r=g\",\"caption\":\"Team Splice\"},\"sameAs\":[\"http:\/\/splice.wpengine.com\",\"http:\/\/facebook.com\/spliceofficial\",\"https:\/\/instagram.com\/splice\",\"https:\/\/x.com\/http:\/\/twitter.com\/splice\",\"https:\/\/www.youtube.com\/channel\/UCb8xLPa5RP8TnCsU7E5ASKQ\"],\"url\":\"https:\/\/splice.com\/blog\/author\/splice\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"iota: Elegant Constants in Golang - Blog | Splice","description":"Learn how to optimize your use of constants in Golang using iota.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/","og_locale":"en_US","og_type":"article","og_title":"iota: Elegant Constants in Golang - Blog | Splice","og_description":"Learn how to optimize your use of constants in Golang using iota.","og_url":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/","og_site_name":"Blog | Splice","article_publisher":"https:\/\/www.facebook.com\/Splice","article_author":"http:\/\/facebook.com\/spliceofficial","article_published_time":"2014-08-29T16:25:19+00:00","article_modified_time":"2024-01-18T19:43:27+00:00","og_image":[{"width":1024,"height":768,"url":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg","type":"image\/jpeg"}],"author":"Team Splice","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/splice","twitter_site":"@splice","twitter_misc":{"Written by":"Team Splice","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#article","isPartOf":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/"},"author":{"name":"Team Splice","@id":"https:\/\/splice.com\/blog\/#\/schema\/person\/1264212de6b56a47de705ec3ad103943"},"headline":"iota: Elegant Constants in Golang","datePublished":"2014-08-29T16:25:19+00:00","dateModified":"2024-01-18T19:43:27+00:00","mainEntityOfPage":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/"},"wordCount":622,"publisher":{"@id":"https:\/\/splice.com\/blog\/#organization"},"image":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage"},"thumbnailUrl":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg","keywords":["engineering"],"articleSection":["Engineering"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/","url":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/","name":"iota: Elegant Constants in Golang - Blog | Splice","isPartOf":{"@id":"https:\/\/splice.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage"},"image":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage"},"thumbnailUrl":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg","datePublished":"2014-08-29T16:25:19+00:00","dateModified":"2024-01-18T19:43:27+00:00","description":"Learn how to optimize your use of constants in Golang using iota.","breadcrumb":{"@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#primaryimage","url":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg","contentUrl":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2014\/08\/3597105175_80b3a2acdf_b.jpg","width":1024,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/splice.com\/blog\/iota-elegant-constants-golang\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/splice.com\/blog\/"},{"@type":"ListItem","position":2,"name":"iota: Elegant Constants in Golang"}]},{"@type":"WebSite","@id":"https:\/\/splice.com\/blog\/#website","url":"https:\/\/splice.com\/blog\/","name":"Splice Blog","description":"An inside look at making music","publisher":{"@id":"https:\/\/splice.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/splice.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/splice.com\/blog\/#organization","name":"Splice","alternateName":"Splice Sounds","url":"https:\/\/splice.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/splice.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2023\/09\/Splice-logo-black-background.png","contentUrl":"https:\/\/splice.com\/blog\/wp-content\/uploads\/2023\/09\/Splice-logo-black-background.png","width":2928,"height":1540,"caption":"Splice"},"image":{"@id":"https:\/\/splice.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Splice","https:\/\/x.com\/splice","https:\/\/www.instagram.com\/splice\/","https:\/\/www.youtube.com\/@splice","https:\/\/discord.com\/invite\/splice"]},{"@type":"Person","@id":"https:\/\/splice.com\/blog\/#\/schema\/person\/1264212de6b56a47de705ec3ad103943","name":"Team Splice","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/splice.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4428b1733406dca9c238897202320bb3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4428b1733406dca9c238897202320bb3?s=96&d=mm&r=g","caption":"Team Splice"},"sameAs":["http:\/\/splice.wpengine.com","http:\/\/facebook.com\/spliceofficial","https:\/\/instagram.com\/splice","https:\/\/x.com\/http:\/\/twitter.com\/splice","https:\/\/www.youtube.com\/channel\/UCb8xLPa5RP8TnCsU7E5ASKQ"],"url":"https:\/\/splice.com\/blog\/author\/splice\/"}]}},"_links":{"self":[{"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/posts\/805"}],"collection":[{"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":1,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":30414,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions\/30414"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/media\/809"}],"wp:attachment":[{"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/splice.com\/blog\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}