﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-++wythern++</title><link>http://www.cppblog.com/wythern/</link><description>X presents Y for a better Z</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 09:41:51 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 09:41:51 GMT</pubDate><ttl>60</ttl><item><title>[转]在Linux下如何创建ramdisk</title><link>http://www.cppblog.com/wythern/archive/2020/02/26/217165.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Wed, 26 Feb 2020 07:17:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2020/02/26/217165.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/217165.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2020/02/26/217165.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/217165.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/217165.html</trackback:ping><description><![CDATA[<p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Refer to&nbsp;<a href="https://www.linuxbabe.com/command-line/create-ramdisk-linux" title="How to Easily Create Ramdisk on Linux">How to Easily Create Ramdisk on Linux</a><br /><br />This tutorial will show you how to quickly create a&nbsp;<strong>RAM disk</strong>&nbsp;in any Linux distro (Debian, Ubuntu, Linux, Fedora, Arch Linux, CentOS, etc). Compared to commercial Windows RAM disk software that costs money, Linux can utilize this cool feature 100% free of charge.</p><h2>What is RAM Disk?</h2><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><strong>RAM disk</strong>&nbsp;is also known as&nbsp;<strong>RAM drive</strong>. It&#8217;s a portion of your RAM that are formated with a file system. You can mount it to a directory on your Linux system and use it as a disk partition.</p><h2>Why use RAM disk?</h2><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">RAM is ultra-fast compared to even the fastest solid state drive (SSD). As you may know, the main performance bottleneck in today&#8217;s computer is the speed of hard drive, so moving programs and files to the RAM disk yields super fast computing experience.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Pros of RAM disk:</p><ul style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><li>Ultra-fast</li><li>Can sustain countless reads and writes</li></ul><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Cons of RAM disk:</p><ul style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><li>RAM is volatile which means all data in RAM disk will be lost when the computer shutdowns or reboots. However, this can be a pro in some situations, if you use it wisely.</li><li>RAM is expensive so it has limited capacity. You need to make sure not allocate too much space for RAM disk, or the operating system would run out of RAM.</li></ul><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">You can do a lot of interesting things with RAM disk.</p><ul style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><li>RAM disk is best suited for temporary data or caching directories, such as&nbsp;<a href="https://www.linuxbabe.com/nginx/setup-nginx-fastcgi-cache" target="_blank" rel="noopener noreferrer" style="text-decoration-line: none; color: #1e73be; border-bottom: 1px solid #1e73be;">Nginx FastCGI cache</a>. If you use a SSD and there will be a lot of writes to a particular directory, you can mount that directory as a RAM disk to reduce wear out of SSD.</li><li>I also use RAM disk to temporary store screenshots when writing articles on this blog, so when my computer shut down, those screenshots will automatically be deleted on my computer.</li><li>You may not believe it, but I use RAM disk to run virtual machines inside VirtualBox. My SSD is about 250G. I can&#8217;t run many VMs directly on the SSD and I&#8217;m not happy about the speed of my 2TB mechanical hard drive (HDD). I can move the VM from HDD to RAM disk before starting the VM, so the VM can run much faster.&nbsp; After shutting down the VM, I move the VM files back to HDD, which takes less than 1 minute. This of course requires your computer to have a large capacity RAM.</li></ul><h2>How to Create a RAM Disk in Any Linux Distro</h2><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">First make a directory which can be anywhere in the file system such as</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo mkdir /tmp/ramdisk</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">If you want to let every user on your Linux system use the RAM disk, then change its permission to 777.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo chmod 777 /tmp/ramdisk</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Next, check how much free RAM are left on your system with&nbsp;<code style="background: #dedede; padding: 1px; font-size: 15px; font-family: &quot;Roboto Mono&quot;, monospace;">htop</code>&nbsp;command line utility because we don&#8217;t want to use too much RAM.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">htop</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><img size-full=""  wp-image-18880"="" src="https://www.linuxbabe.com/wp-content/uploads/2016/08/easily-create-ram-disk-linux.png" alt="easily create ram disk linux" width="734" height="462" srcset="https://www.linuxbabe.com/wp-content/uploads/2016/08/easily-create-ram-disk-linux.png 734w, https://www.linuxbabe.com/wp-content/uploads/2016/08/easily-create-ram-disk-linux-348x219.png 348w, https://www.linuxbabe.com/wp-content/uploads/2016/08/easily-create-ram-disk-linux-572x360.png 572w, https://www.linuxbabe.com/wp-content/uploads/2016/08/easily-create-ram-disk-linux-640x403.png 640w" sizes="(max-width: 734px) 100vw, 734px" style="max-width: 100%; display: block; margin: 5px auto; height: auto;" /></p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Then all left to do is to specify the&nbsp;<strong>file system type</strong>,&nbsp;<strong>RAM disk size</strong>,&nbsp;<strong>device name</strong>&nbsp;and mount it to the above directory. You can see from the screenshot above that I have plenty of free RAM, so I can easily allocate 1GB for my RAM disk. This can be done with the following one-liner. It will be using&nbsp;<code style="background: #dedede; padding: 1px; font-size: 15px; font-family: &quot;Roboto Mono&quot;, monospace;">tmpfs</code>&nbsp;file system and its size is set to 1024MB.&nbsp;<code style="background: #dedede; padding: 1px; font-size: 15px; font-family: &quot;Roboto Mono&quot;, monospace;">myramdisk</code>&nbsp;is the device name I gave to it.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo mount -t tmpfs -o size=1024m myramdisk /tmp/ramdisk</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">To allocate 10G for the RAM disk, run this instead.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo mount -t tmpfs -o size=10G myramdisk /tmp/ramdisk</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">If we issue the following command</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">mount | tail -n 1</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">We can see it&#8217;s successfully mounted.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><img size-full=""  wp-image-18881"="" src="https://www.linuxbabe.com/wp-content/uploads/2016/08/create-linux-ramdisk.png" alt="create linux ramdisk" width="734" height="98" srcset="https://www.linuxbabe.com/wp-content/uploads/2016/08/create-linux-ramdisk.png 734w, https://www.linuxbabe.com/wp-content/uploads/2016/08/create-linux-ramdisk-400x53.png 400w, https://www.linuxbabe.com/wp-content/uploads/2016/08/create-linux-ramdisk-661x88.png 661w, https://www.linuxbabe.com/wp-content/uploads/2016/08/create-linux-ramdisk-640x85.png 640w" sizes="(max-width: 734px) 100vw, 734px" style="max-width: 100%; display: block; margin: 5px auto; height: auto;" /></p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Now if I copy my VirtualBox machines file (5.8G) into the RAM disk, my RAM usage suddenly goes up to 9.22G.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><img size-full=""  wp-image-18882"="" src="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-automount-ramdisk.png" alt="linux automount ramdisk" width="734" height="183" srcset="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-automount-ramdisk.png 734w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-automount-ramdisk-400x100.png 400w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-automount-ramdisk-661x165.png 661w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-automount-ramdisk-640x160.png 640w" sizes="(max-width: 734px) 100vw, 734px" style="max-width: 100%; display: block; margin: 5px auto; height: auto;" /></p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">If I unmount RAM disk,</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo umount /tmp/ramdisk/</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Everything in that directory will be lost and RAM usage goes down to original.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><img size-full=""  wp-image-18883"="" src="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-file-system.png" alt="linux ramdisk file system" width="734" height="177" srcset="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-file-system.png 734w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-file-system-400x96.png 400w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-file-system-661x159.png 661w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-file-system-640x154.png 640w" sizes="(max-width: 734px) 100vw, 734px" style="max-width: 100%; display: block; margin: 5px auto; height: auto;" /></p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">This is how you can test if your RAM disk is working.</p><h2>Test RAM Disk Speed</h2><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">To test write speed of RAM disk, you can use dd utility.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo dd if=/dev/zero of=/tmp/ramdisk/zero bs=4k count=100000</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Which gave me&nbsp;<strong>2.8GB/s write speed</strong>.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><img size-full=""  wp-image-18884"="" src="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-speed-test.png" alt="linux ramdisk speed test" width="761" height="134" srcset="https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-speed-test.png 761w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-speed-test-400x70.png 400w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-speed-test-661x116.png 661w, https://www.linuxbabe.com/wp-content/uploads/2016/08/linux-ramdisk-speed-test-640x113.png 640w" sizes="(max-width: 761px) 100vw, 761px" style="max-width: 100%; display: block; margin: 5px auto; height: auto;" /></p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">To test read speed, run:</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo dd if=/tmp/ramdisk/zero of=/dev/null bs=4k count=100000</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Which gave me&nbsp;<strong>3.1 GB/s read speed</strong>.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">I also did a speed test on my SSD. The write speed is&nbsp;<strong>534MB/s</strong>&nbsp;and read speed&nbsp;<strong>1.6GB/s</strong>.</p><h2>Auto-mount on System Boot</h2><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Edit&nbsp;<code style="background: #dedede; padding: 1px; font-size: 15px; font-family: &quot;Roboto Mono&quot;, monospace;">/etc/fstab</code>&nbsp;file.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo nano /etc/fstab</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">Add an entry like this:</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">myramdisk  /tmp/ramdisk  tmpfs  defaults,size=1G,x-gvfs-show  0  0</pre><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;"><code style="background: #dedede; padding: 1px; font-size: 15px; font-family: &quot;Roboto Mono&quot;, monospace;">x-gvfs-show</code>&nbsp;will let you see your RAM disk in file manager. Save and close the file. Your Linux system will automatically mount the RAM disk when your computer boots up.</p><p style="font-family: &quot;Fira Sans&quot;; font-size: 16px; background-color: #f9f9f9;">To mount it immediately without reboot, run the following command.</p><pre style="font-size: 16px; font-family: &quot;Roboto Mono&quot;, monospace; word-break: break-all; overflow: auto; white-space: pre-wrap; background: rgba(0, 0, 0, 0.03); border-left: 4px solid rgba(0, 0, 0, 0.1); padding: 15px; overflow-wrap: break-word;">sudo mount -a</pre><img src ="http://www.cppblog.com/wythern/aggbug/217165.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2020-02-26 15:17 <a href="http://www.cppblog.com/wythern/archive/2020/02/26/217165.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在truffle或其他测试环境下如何得到contract的返回值</title><link>http://www.cppblog.com/wythern/archive/2019/11/28/217004.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Thu, 28 Nov 2019 10:13:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2019/11/28/217004.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/217004.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2019/11/28/217004.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/217004.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/217004.html</trackback:ping><description><![CDATA[<p>&nbsp; &nbsp; 1. 使用pure或者view函数，直接拿到返回值，但不是所有的函数都能声明成pure/view。</p> <p>&nbsp; &nbsp; 2. 使用event包装返回值，但是在emit之前返回的函数是没有event的，如果需要每条path都返回有意义的return value，可能需要定义很多个event。（不考虑require throw的情况下）</p> <p>&nbsp; &nbsp; 3. 使用web3.eth.Contract.call，需要ABI和deployed address，这个用法有个缺点是将函数变成了constant的，即和1一样无法改变合约内部状态，只能说在特定的场景下有用。</p> <p>&nbsp; &nbsp; 4. EIP-758(<a href="https://eips.ethereum.org/EIPS/eip-758">https://eips.ethereum.org/EIPS/eip-758</a>)，返回returnData在subscribe的通道上，但是看目前的状态还是draft。</p> <p><br /></p><img src ="http://www.cppblog.com/wythern/aggbug/217004.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2019-11-28 18:13 <a href="http://www.cppblog.com/wythern/archive/2019/11/28/217004.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]CRLF和LF在跨平台工作时候带来的烦恼以及解决方法</title><link>http://www.cppblog.com/wythern/archive/2019/03/27/216318.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Wed, 27 Mar 2019 05:29:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2019/03/27/216318.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/216318.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2019/03/27/216318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/216318.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/216318.html</trackback:ping><description><![CDATA[原文<a href="https://www.jianshu.com/p/dd7464cf32b5">在此</a><br /><br /><div><div><p>在使用git提交代码时候，有时候会遇到一个问题，就是自己明明只修改了其中几行，提交上去以后发现整个文件都被修改了，在设置了格式风格以后还会有提交不上去的情况，这个时候经常让人摸不到头脑，其实就是CRLF和LF在作怪</p> <h2>CRLF LF CR 都是什么意思：</h2> <ul> <li><p>CRLF: 是carriagereturnlinefeed的缩写。中文意思是回车换行。</p></li> <li><p>LF: 是line feed的缩写，中文意思是换行。</p></li> <li><p>CR: 是carriagereturn的缩写。中文意思是回车。</p></li> </ul> <p><strong>简单的换行回车为什么会引出这么多的问题呢，关键在于操作系统之间的分歧：</strong></p> <p>早期的mac系统使用CR当做换行，现在也已经统一成了LF</p> <p>Unix(包含现在大量使用的linux)系统使用LF</p> <p>windows系统使用LFCR当做换行（自作聪明的兼容性？？）</p> <p>也正是因为不同系统的分歧，在多人协作共同开发的时候，可能导致提交代码时候产生问题。</p> <h2>解决方法：</h2> <p>Android Studio内部可以设置不同模式，具体位置在setting--&gt;搜索code style见下图：</p><div><div style="max-width: 700px; max-height: 438px;"> <div data-width="1308" data-height="820"><img data-original-src="//upload-images.jianshu.io/upload_images/4623936-3f3b14e2b2dc566b.png" src="//upload-images.jianshu.io/upload_images/4623936-3f3b14e2b2dc566b.png" data-original-width="1308" data-original-height="820" data-original-format="image/png" data-original-filesize="121145" style="cursor: zoom-in;" alt="" /></div> </div> <div><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />设置格式</div> </div> <p>其中有四个选项System-Dependent LF CR CRLF，默认是System-Dependent，也就是根据你是什么系统选择什么类型，如果想要自定义的话可以在这里设置，以后创建的新代码也默认用设置的方式</p> <p>而如果想单独修改某个文件的类型，也可以在右下角进行修改，见下图：</p> <div> <div style="max-width: 564px; max-height: 209px;"> <div style="padding-bottom: 37.059999999999995%;"></div> <div data-width="564" data-height="209"><img data-original-src="//upload-images.jianshu.io/upload_images/4623936-77cb58136c0fd9a2.png" src="//upload-images.jianshu.io/upload_images/4623936-77cb58136c0fd9a2.png" data-original-width="564" data-original-height="209" data-original-format="image/png" data-original-filesize="11222" style="cursor: zoom-in;" alt="" /></div> </div> <div>单独修改某个文件</div> </div> <h2>跨平台合作时候的解决方式：</h2> <p>当我们使用git库提交代码的时候，有的人可能使用mac，有的人使用linux，有的人使用windows，不同的开发环境如果都是按照自己系统的方式任意修改换行类型，难免会让代码库整体混乱或者产生许多没有必要的代码更新</p> <p><strong>那么解决该问题的方式有：core.autocrlf命令</strong></p> <p>git为了防止以上问题扰乱跨平台合作开发，使用命令可以转化LF和CRLF</p> <p>具体体现为：</p> <ul> <li>git config --global core.autocrlf true</li> </ul> <p><br />Git可以在你push时自动地把行结束符CRLF转换成LF，而在pull代码时把LF转换成CRLF。用core.autocrlf来打开此项功能，如果是在Windows系统上，把它设置成true，这样当签出代码时，LF会被转换成CRLF</p> <ul> <li>git config --global core.autocrlf input</li> </ul> <p>Linux或Mac系统使用LF作为行结束符；当一个以CRLF为行结束符的文件不小心被引入时你肯定想进行修正，把core.autocrlf设置成input来告诉 Git 在push时把CRLF转换成LF，pull时不转换</p> <ul> <li>git config --global core.autocrlf false</li> </ul> <p>在本地和代码库中都保留CRLF，无论pull还是push都不变，代码库什么样，本地还是什么样子</p> <p><strong>当然在多人跨平台工作时候，最好还是约定使用LF，还是CRLF，然后不同系统进行对应的设置，这样是工作规范，也有利于提高工作效率，希望以上可以帮助大家。</strong></p></div><br /><br />作者：sososun<br />链接：https://www.jianshu.com/p/dd7464cf32b5<br />来源：简书<br />简书著作权归作者所有，任何形式的转载都请联系作者获得授权并注明出处。</div><img src ="http://www.cppblog.com/wythern/aggbug/216318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2019-03-27 13:29 <a href="http://www.cppblog.com/wythern/archive/2019/03/27/216318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>How to shuffle arrays and slices in Go</title><link>http://www.cppblog.com/wythern/archive/2019/01/17/216208.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Thu, 17 Jan 2019 12:27:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2019/01/17/216208.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/216208.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2019/01/17/216208.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/216208.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/216208.html</trackback:ping><description><![CDATA[原文<a href="https://www.calhoun.io/how-to-shuffle-arrays-and-slices-in-go/">在此<br /><br />由于</a>Go没有为slice提供shuffle函数，所以需要自己想办法。由于我只需要随机一次遍历1 -&gt; N，所以这段code最匹配。<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->func&nbsp;main()&nbsp;{<br />&nbsp;&nbsp;vals&nbsp;:=&nbsp;[]<span style="color: #0000FF; ">int</span>{10,&nbsp;12,&nbsp;14,&nbsp;16,&nbsp;18,&nbsp;20}<br />&nbsp;&nbsp;r&nbsp;:=&nbsp;rand.New(rand.NewSource(time.Now().Unix()))<br />&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;_,&nbsp;i&nbsp;:=&nbsp;range&nbsp;r.Perm(len(vals))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;val&nbsp;:=&nbsp;vals[i]<br />&nbsp;&nbsp;&nbsp;&nbsp;fmt.Println(val)<br />&nbsp;&nbsp;}<br />}</div><br />似乎go不像scala有那种惰性求值的特性，所以这里的r.Perm()还是产生了一个slice，如果N很大可能是个问题。<br /><br /><br /><br /><img src ="http://www.cppblog.com/wythern/aggbug/216208.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2019-01-17 20:27 <a href="http://www.cppblog.com/wythern/archive/2019/01/17/216208.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>go test 用args带参数</title><link>http://www.cppblog.com/wythern/archive/2018/08/14/215845.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Tue, 14 Aug 2018 09:04:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2018/08/14/215845.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215845.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2018/08/14/215845.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215845.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215845.html</trackback:ping><description><![CDATA[<div>测试中想通过命令行传递一些参数给test func，网上找了一些资料但过程不是很顺利，这里记录一下。</div>
<div></div>
<div>首先go test有一个-args的参数说可以达到这个目的，但实测下来发现有没有没区别。。。</div>
<div>google查到的大部分也是用到了flag类型。</div>
<div>flag.go的注释写的比较清楚</div>
<div>
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008000; ">/*</span><span style="color: #008000; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;Package&nbsp;flag&nbsp;implements&nbsp;command-line&nbsp;flag&nbsp;parsing.<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Usage:<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Define&nbsp;flags&nbsp;using&nbsp;flag.String(),&nbsp;Bool(),&nbsp;Int(),&nbsp;etc.<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;declares&nbsp;an&nbsp;integer&nbsp;flag,&nbsp;-flagname,&nbsp;stored&nbsp;in&nbsp;the&nbsp;pointer&nbsp;ip,&nbsp;with&nbsp;type&nbsp;*int.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;"flag"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;ip&nbsp;=&nbsp;flag.Int("flagname",&nbsp;1234,&nbsp;"help&nbsp;message&nbsp;for&nbsp;flagname")<br />
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;you&nbsp;like,&nbsp;you&nbsp;can&nbsp;bind&nbsp;the&nbsp;flag&nbsp;to&nbsp;a&nbsp;variable&nbsp;using&nbsp;the&nbsp;Var()&nbsp;functions.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;flagvar&nbsp;int<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func&nbsp;init()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag.IntVar(&amp;flagvar,&nbsp;"flagname",&nbsp;1234,&nbsp;"help&nbsp;message&nbsp;for&nbsp;flagname")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;Or&nbsp;you&nbsp;can&nbsp;create&nbsp;custom&nbsp;flags&nbsp;that&nbsp;satisfy&nbsp;the&nbsp;Value&nbsp;interface&nbsp;(with<br />
&nbsp;&nbsp;&nbsp;&nbsp;pointer&nbsp;receivers)&nbsp;and&nbsp;couple&nbsp;them&nbsp;to&nbsp;flag&nbsp;parsing&nbsp;by<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag.Var(&amp;flagVal,&nbsp;"name",&nbsp;"help&nbsp;message&nbsp;for&nbsp;flagname")<br />
&nbsp;&nbsp;&nbsp;&nbsp;For&nbsp;such&nbsp;flags,&nbsp;the&nbsp;default&nbsp;value&nbsp;is&nbsp;just&nbsp;the&nbsp;initial&nbsp;value&nbsp;of&nbsp;the&nbsp;variable.<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;After&nbsp;all&nbsp;flags&nbsp;are&nbsp;defined,&nbsp;call<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag.Parse()<br />
&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;parse&nbsp;the&nbsp;command&nbsp;line&nbsp;into&nbsp;the&nbsp;defined&nbsp;flags.<br />
<img src="http://www.cppblog.com/Images/dot.gif" alt="" /><br />
</span><span style="color: #008000; ">*/</span></div>
</div>
<div></div>
<div>因此需要做的事情就是：</div>
<div>1. 定义flag，这个需要在main()执行之前完成，我这里在test文件里面用全局变量完成，但a可以放在函数里面。</div>
<div>
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000; ">var&nbsp;(<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;Define&nbsp;global&nbsp;args&nbsp;flags.</span><span style="color: #008000; "><br />
</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;pA&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;flag.Int(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">a</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">,&nbsp;&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">a.</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />
&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">0</span><span style="color: #000000; "><br />
)</span></div>
</div>
<div>2. parse flag，这个要在test func执行之前，所以可以考虑加入一个init()在test文件里。</div>
<div>
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000; ">func&nbsp;init()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;flag.Parse()<br />
&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">pA<br />
}</span></div>
</div>
<div>后面使用这些变量就没有问题了，比如这样</div>
<div>
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000; ">func&nbsp;TestInit(t&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">testing.T)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;flag.Parse()<br />
&nbsp;&nbsp;&nbsp;&nbsp;t.Log(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">a&nbsp;=&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&nbsp;a)<br />
}<br />
</span></div>
</div>
<div></div>
<div>这里用到的主要是flag的功能，测试用发现有没有-args问题不大，所以这个用法可能不是很符合go test的要求，先用起来再说了。</div>
<div></div>
<div></div>
<div></div><div></div><div>REF</div>
<div>1. https://www.golangtc.com/t/584cbd16b09ecc2e1800000b</div>
<div>2. https://stackoverflow.com/.../process-command-line-arguments-in-go-test</div><div>3. https://hsulei.com/2017/08/23/gotest如何使用自定义参数/</div>
<div><cite><br /></cite></div>
<div></div><img src ="http://www.cppblog.com/wythern/aggbug/215845.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2018-08-14 17:04 <a href="http://www.cppblog.com/wythern/archive/2018/08/14/215845.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]shell中if条件字符串、数字比对，[[ ]]和[ ]区别</title><link>http://www.cppblog.com/wythern/archive/2018/08/14/215844.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Tue, 14 Aug 2018 08:44:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2018/08/14/215844.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215844.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2018/08/14/215844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215844.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215844.html</trackback:ping><description><![CDATA[<p style="margin: 10px auto; line-height: 1.5; text-indent: 0px; caret-color: #000000; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 14.399999618530273px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">原文<a href="https://www.cnblogs.com/include/archive/2011/12/09/2307905.html">在此</a><br /></p><p style="margin: 10px auto; line-height: 1.5; text-indent: 0px; caret-color: #000000; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 14.399999618530273px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">学习shell的时候总是被shell里的条件判断方式搞得头疼，经常不知道改 用[],[[]],(())还是test,let，而很少有书把它们的关系讲解的很清楚(应该是我悟性差或是看书太少)，今天总结一下，基础的东西如它们 的使用方法不再赘述，重点说说它们的区别的使用时应该注意的地方。<br /><br />先说[]和test，两者是一样的，在命令行里test expr和[ expr ]的效果相同。test的三个基本作用是判断文件、判断字符串、判断整数。支持使用与或非将表达式连接起来。要注意的有：<br /><br />1.test中可用的比较运算符只有==和!=，两者都是用于字符串比较的，不可用于整数比较，整数比较只能使用-eq, -gt这种形式。无论是字符串比较还是整数比较都千万不要使用大于号小于号。当然，如果你实在想用也是可以的，对于字符串比较可以使用尖括号的转义形式， 如果比较"ab"和"bc"：[ ab \&lt; bc ]，结果为真，也就是返回状态为0.<br /><br />然后是[[ ]]，这是内置在shell中的一个命令，它就比刚才说的test强大的多了。支持字符串的模式匹配（使用=~操作符时甚至支持shell的正则表达 式）。简直强大的令人发指！逻辑组合可以不使用test的-a,-o而使用&amp;&amp;,||这样更亲切的形式(针对c、Java程序员)。当 然，也不用想的太复杂，基本只要记住<br />1.字符串比较时可以把右边的作为一个模式（这是右边的字符串不加双引号的情况下。如果右边的字符串加了双引号，则认为是一个文本字符串。），而不仅仅是一个字符串，比如[[ hello == hell? ]]，结果为真。</p><p style="margin: 10px auto; line-height: 1.5; text-indent: 0px; caret-color: #000000; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 14.399999618530273px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">另外要注意的是，使用[]和[[]]的时候不要吝啬空格，每一项两边都要有空格，[[ 1 == 2 ]]的结果为&#8220;假&#8221;，但[[ 1==2 ]]的结果为&#8220;真&#8221;！后一种显然是错的</p><p style="margin: 10px auto; line-height: 1.5; text-indent: 0px; caret-color: #000000; color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 14.399999618530273px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><br />3.最后就是let和(())，两者也是一样的(或者说基本上是一样的，双括号比let稍弱一些)。主要进行算术运算(上面的两个都不行)，也比较适合进 行整数比较，可以直接使用熟悉的&lt;,&gt;等比较运算符。可以直接使用变量名如var而不需要$var这样的形式。支持分号隔开的多个表达式</p><img src ="http://www.cppblog.com/wythern/aggbug/215844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2018-08-14 16:44 <a href="http://www.cppblog.com/wythern/archive/2018/08/14/215844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一张图了解公链和私链</title><link>http://www.cppblog.com/wythern/archive/2018/08/01/215813.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Wed, 01 Aug 2018 06:05:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2018/08/01/215813.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215813.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2018/08/01/215813.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215813.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215813.html</trackback:ping><description><![CDATA[<div><img src="https://cdn-images-1.medium.com/max/1600/0*s0QUH2j9SAetBKQv." alt="" longdesc="private_and_public_chain" /><img src="http://www.cppblog.com/images/cppblog_com/wythern/0_x2A_s0QUH2j9SAetBKQv..png" alt="" longdesc="private_and_public_chain" /></div><div>图片来源：https://blog.slock.it/public-vs-private-chain-7b7ca45044f</div><img src ="http://www.cppblog.com/wythern/aggbug/215813.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2018-08-01 14:05 <a href="http://www.cppblog.com/wythern/archive/2018/08/01/215813.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Full go tool list (keep constructing)</title><link>http://www.cppblog.com/wythern/archive/2018/07/21/215794.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Sat, 21 Jul 2018 06:09:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2018/07/21/215794.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215794.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2018/07/21/215794.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215794.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215794.html</trackback:ping><description><![CDATA[REF:&nbsp; https://dominik.honnef.co/posts/2014/12/an_incomplete_list_of_go_tools/<br /><br /><div>go get github.com/golang/lint/golint</div><div>go get github.com/kisielk/errcheck</div><div>go get golang.org/x/tools/cmd/benchcmp</div><div>go get github.com/cespare/prettybench</div><div>go get github.com/ajstarks/svgo/benchviz</div><div>go get golang.org/x/tools/cmd/stringer</div><div>go get github.com/josharian/impl</div><div>go get golang.org/x/tools/cmd/goimports</div><div>go get sourcegraph.com/sqs/goreturns</div><div>go get code.google.com/p/rog-go/exp/cmd/godef</div><div>go get github.com/nsf/gocode</div><div>go get golang.org/x/tools/cmd/oracle</div><div>go get golang.org/x/tools/cmd/gorename</div><div>go get github.com/kisielk/godepgraph</div><div></div><img src ="http://www.cppblog.com/wythern/aggbug/215794.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2018-07-21 14:09 <a href="http://www.cppblog.com/wythern/archive/2018/07/21/215794.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Some materials about RPC transaction call.</title><link>http://www.cppblog.com/wythern/archive/2018/07/14/215784.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Sat, 14 Jul 2018 09:00:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2018/07/14/215784.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215784.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2018/07/14/215784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215784.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215784.html</trackback:ping><description><![CDATA[<div><h2>Introduction</h2></div><div>Solidiay doc about ABI and contract access.<br /> </div><div>https://solidity.readthedocs.io/en/develop/abi-spec.html</div><div>https://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts.html?highlight=selfdestruct</div><div>http://www.ethdocs.org/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html</div><div>http://ethdocs.org/en/latest/contracts-and-transactions/contracts.html#testing-contracts-and-transactions</div><div>https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=suicide [global variables like msg.sender]</div><div></div><div>ABI intro in Ethereum Wiki.</div><div>https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#argument-encoding</div><div>https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial</div><div></div><div>JAON rpc api of Eth.</div><div>https://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-api</div><div>https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods</div><div></div><div>Deploy a contract using RPC.</div><div>https://github.com/rsksmart/rskj/wiki/Deploying-contracts-using-RPC-calls</div><div></div><div><span class="col-11 text-gray-dark mr-2" itemprop="about">A tool to generate the grpc server code for a contract <br /></span></div><div><span class="col-11 text-gray-dark mr-2" itemprop="about">https://github.com/getamis/grpc-contract</span></div><div><span class="col-11 text-gray-dark mr-2" itemprop="about"><br /></span></div><div><h2><span class="col-11 text-gray-dark mr-2" itemprop="about">How to test.</span></h2><div>http://ethereum-tests.readthedocs.io/en/latest/test_types/transaction_tests.html</div><div>https://github.com/ethereum/cpp-ethereum/blob/develop/doc/generating_tests.rst</div><div></div><div>go-ethereum里面有一批vm和contract相关的tests，结合ABI和contract的定义，可以很容易的写一批自己定制的测试，从web3js或者直接在go project里面调用都可以。</div><div></div></div><div><span class="col-11 text-gray-dark mr-2" itemprop="about"><br /></span></div><img src ="http://www.cppblog.com/wythern/aggbug/215784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2018-07-14 17:00 <a href="http://www.cppblog.com/wythern/archive/2018/07/14/215784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>What is shade jar, and what is its purpose.</title><link>http://www.cppblog.com/wythern/archive/2017/06/19/215009.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Mon, 19 Jun 2017 03:23:00 GMT</pubDate><guid>http://www.cppblog.com/wythern/archive/2017/06/19/215009.html</guid><wfw:comment>http://www.cppblog.com/wythern/comments/215009.html</wfw:comment><comments>http://www.cppblog.com/wythern/archive/2017/06/19/215009.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wythern/comments/commentRss/215009.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wythern/services/trackbacks/215009.html</trackback:ping><description><![CDATA[<div><div itemprop="text"> <p><div>https://stackoverflow.com/questions/13620281/what-is-the-maven-shade-plugin-used-for-and-why-would-you-want-to-relocate-java</div></p><p><br /></p><p>Uber JAR, in short, is a JAR containing everything.</p>  <p>Normally in Maven, we rely on dependency management. An artifact contains only the classes/resources of itself. Maven will be responsible to find out all artifacts (JARs etc) that the project depending on when the project is built.</p>  <p>An uber-jar is something that take all dependencies, and extract the content of the dependencies and put them with the classes/resources of the project itself, in one big JAR. By having such uber-jar, it is easy for execution, because you will need only one big JAR instead of tons of small JARs to run your app. It also ease distribution in some case.</p>  <p>Just a side-note. Avoid using uber-jar as Maven dependency, as it is ruining the dependency resolution feature of Maven. Normally we create uber-jar only for the final artifact for actual deployment or for manual distribution, but not for putting to Maven repository.</p>  <hr />  <p>Update: I have just discovered I haven't answered one part of the question : "What's the point of renaming the packages of the dependencies?". Here is some brief updates and hopefully will help people having similar question.</p>  <p>Creating uber-jar for ease of deployment is one use case of shade plugin. There are also other common use cases which involve package renaming.</p>  <p>For example, I am developing <code>Foo</code> library, which depends on a specific version (e.g. 1.0) of <code>Bar</code> library. Assuming I cannot make use of other version of <code>Bar</code> lib (because API change, or other technical issues, etc). If I simply declare <code>Bar:1.0</code> as <code>Foo</code>'s dependency in Maven, it is possible to fall into a problem: A <code>Qux</code> project is depending on <code>Foo</code>, and also <code>Bar:2.0</code> (and it cannot use <code>Bar:1.0</code> because <code>Qux</code> needs to use new feature in <code>Bar:2.0</code>). Here is the dilemma: should <code>Qux</code> use <code>Bar:1.0</code> (which <code>Qux</code>'s code will not work) or <code>Bar:2.0</code> (which <code>Foo</code>'s code will not work)?</p>  <p>In order to solve this problem, developer of <code>Foo</code> can choose to use shade plugin to rename its usage of <code>Bar</code>, so that all classes in <code>Bar:1.0</code> jar are embedded in <code>Foo</code> jar, and the package of the embedded <code>Bar</code> classes is changed from <code>com.bar</code> to <code>com.foo.bar</code>. By doing so, <code>Qux</code> can safely depends on <code>Bar:2.0</code> because now <code>Foo</code> is no longer depending on <code>Bar</code>, and it is using is own copy of "altered" <code>Bar</code> located in another package.</p>     </div></div><img src ="http://www.cppblog.com/wythern/aggbug/215009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wythern/" target="_blank">wythern</a> 2017-06-19 11:23 <a href="http://www.cppblog.com/wythern/archive/2017/06/19/215009.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>