<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ques0942</title>
    <description>The latest articles on DEV Community by ques0942 (@ques0942).</description>
    <link>https://dev.to/ques0942</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F49532%2Fd1d883ee-933a-4af5-b1ad-621ff103265c.png</url>
      <title>DEV Community: ques0942</title>
      <link>https://dev.to/ques0942</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ques0942"/>
    <language>en</language>
    <item>
      <title>jq sample(definition syntax for variable and function)</title>
      <dc:creator>ques0942</dc:creator>
      <pubDate>Mon, 01 Apr 2019 12:32:59 +0000</pubDate>
      <link>https://dev.to/ques0942/jq-sample-definition-syntax-for-variable-and-function-ak5</link>
      <guid>https://dev.to/ques0942/jq-sample-definition-syntax-for-variable-and-function-ak5</guid>
      <description>&lt;h1&gt;
  
  
  jq
&lt;/h1&gt;

&lt;h2&gt;
  
  
  use query string from a file
&lt;/h2&gt;

&lt;p&gt;you can write query at a file like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;curl "http://localhost:8080/" | jq -f jq_query
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  variable definition
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '{"a": "valueA"}' |\
  jq '. | {"b": "valueB"} as $v | {"a2": .a, "b2": $v.b}'
# output
# {
#  "a2": "valueA",
#  "b2": "valueB"
#}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  function definition and if statement
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;echo '[{"a": "valueA"}, {"b": "valueB"}]' |  jq '[.[] | 
&lt;/span&gt;&lt;span class="gp"&gt;    def replace(d): d as $&lt;/span&gt;d | 
&lt;span class="gp"&gt;      if (.a == null and .b != null) then {"a": $&lt;/span&gt;d.a, &lt;span class="s2"&gt;"b"&lt;/span&gt;: .b&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="gp"&gt;      elif (.a != null and .b == null) then {"a": .a, "b": $&lt;/span&gt;d.b&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="gp"&gt;      elif (.a == null and .b == null) then {"a": $&lt;/span&gt;d.a, &lt;span class="s2"&gt;"b"&lt;/span&gt;: &lt;span class="nv"&gt;$d&lt;/span&gt;.b&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="go"&gt;      else {"a": .a, "b": .b}
&lt;/span&gt;&lt;span class="gp"&gt;      end;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="go"&gt;    replace({"a": "valueA2", "b": "valueB2"})]'
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;output
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;: &lt;span class="s2"&gt;"valueA"&lt;/span&gt;,
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"b"&lt;/span&gt;: &lt;span class="s2"&gt;"valueB2"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;: &lt;span class="s2"&gt;"valueA2"&lt;/span&gt;,
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"b"&lt;/span&gt;: &lt;span class="s2"&gt;"valueB"&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>jq</category>
      <category>json</category>
    </item>
    <item>
      <title>xerrors has less feature about trace's detail</title>
      <dc:creator>ques0942</dc:creator>
      <pubDate>Thu, 07 Mar 2019 13:48:33 +0000</pubDate>
      <link>https://dev.to/ques0942/xerrors-has-less-feature-about-traces-detail-4861</link>
      <guid>https://dev.to/ques0942/xerrors-has-less-feature-about-traces-detail-4861</guid>
      <description>&lt;p&gt;This is feedback for Go 2 Proposal.&lt;br&gt;
This is my opinion. if you has any opinions for proposals, please &lt;a href="https://go.googlesource.com/proposal/+/master/design/go2draft.md"&gt;feedback&lt;/a&gt; your one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://go.googlesource.com/proposal/+/master/design/go2draft-error-values-overview.md"&gt;The proposal of Go 2 Error Values&lt;/a&gt; is looks good to me. Inspection and printing feature is simple and ease to use. but not enough to read error stacktrace.&lt;br&gt;
Some case(i faced when i used &lt;a href="https://sentry.io/welcome/"&gt;sentry&lt;/a&gt;), we want to read error stacktrace(ie. program counter, function name, line number...etc) to create structured error data. Implementation of this proposal("xerrors") provide Printer interface only which is used to print error.&lt;br&gt;
This interface is focus on printing and formatting so we can't use it to read stacktrace. If i want to read stacktrace by using "xerrors", i must write &lt;a href="https://gist.github.com/ques0942/d2e5e55780b08653adde602ffb247925"&gt;dirty code&lt;/a&gt;.&lt;br&gt;
If "xerrors" will reveals stacktrace or returns runtime.Frame, it will be very useful. so i support &lt;a href="https://gist.github.com/axw/247b6f69d2da016bb21a5eb1be44e611"&gt;this idea&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>go</category>
      <category>golang2</category>
    </item>
  </channel>
</rss>
