<p>Good evening everyone. My current place of employment is very manual by nature and has not seen a drop of automation scripting until I arrived last year. My experience in automating Excel reports made me a perfect candidate for this task although I am starting to find that my scripts are becoming increasingly more difficult to maintain as they increase in number.</p>
<p>I am currently utilizing VBScript as the sole scripting language in our Windows environment and blame the issues that I am facing on this horribly ancient, feature-lacking joke of a scripting language. </p>
<p>With that said, I have been interested in Golang for a while and would like to know your thoughts on using Golang for Windows automation. Below are the main features I am searching for:</p>
<ul>
<li>Support for Windows environment (mainly IO operations)</li>
<li>Support for MS Excel interop</li>
<li>Script linking / calling classes and functions from separate scripts</li>
<li>GUI support or existing GUI libraries</li>
<li>Decent debugging tools</li>
</ul>
<p>Thanks in advance for reading my wall of text :)</p>
<hr/>**评论:**<br/><br/>BoTuLoX: <pre><p>Go is my favorite language, but when it comes to automation Python pops in my mind, not Go.</p>
<p>Automation tasks are the kind of thing that can break often and need frequent hacking. Go is built more for making robust software. Python is more suited to the "move fast and break things" style development IMO. I'm sure someone is doing a gorgeous job at automating everything they do with Go, as there are people doing it in C or Javascript, but Python has a good ecosystem for automation, is forgiving without going too far... just dropping my 2 cents here.</p></pre>mashmorgan: <pre><p>python+Fabric works brilliant for me..</p></pre>vansterdam_city: <pre><p>Agreed. I worked on the CI/automation team at my last job and was asked to write an automated sync tool. I was given the choice of programming language, but both Go and Python were suggested. I ultimately chose to do the work in a scripting language. Mainly for the reasons you stated.</p></pre>yhykes: <pre><p>No. Using Go would be a horrible idea for this.</p>
<p>I'm sure that despite saying I've been primarily a linux user for over 8 years won't keep Gophers from downvoting me for this:</p>
<p>You want PowerShell. You really do. I can't imagine doing what you're asking about in Golang, compared to how trivial it would be in Powershell.</p>
<p>It would be a gigantic mistake to use anything other than Powershell for this. There are a huge number of things that would require you to write thousands of lines of bullshit windows "interop" stuff that won't be a problem when you're dealing with PS/.NET.</p>
<p>ESPECIALLY if you want to do GUI or Excel interop stuff. Guess what? COM baby! You're in Windows land... you might as well use the best tool for the job, and it's undeniably Powershell.</p>
<hr/>
<p>edit: go-ole helps with Excel. But none the less, I don't know all of your requirements, please evaluate PowerShell.</p>
<p>I used to be the guy that would very loudly decry it. After being forced to use it for 6 months, I found myself regularly reaching for it.</p>
<p>If I could use Powershell in Linux (and get to pipe objects with proper structure and fields and validation)..... omg, I think I'd be in heaven. Shell scripting is a joke compared to Powershell.</p></pre>onegeek: <pre><p>You totally want Powershell for this. Integrates with .NET easily, natively works and so on. </p>
<p>I would use Go for things that must work cross platform, and cross compile it. Best of luck. </p></pre>lolomfgkthxbai: <pre><blockquote>
<p>I'm sure that despite saying I've been primarily a linux user for over 8 years won't keep Gophers from downvoting me for this:</p>
</blockquote>
<p>Saying rational things in <a href="/r/golang">/r/golang</a> or <a href="/r/programming">/r/programming</a> won't get people downvoted. This isn't <a href="/r/politics">/r/politics</a>. :P</p></pre>ptman: <pre><p><a href="https://github.com/Pash-Project/Pash" rel="nofollow">PowerShell for Linux</a></p></pre>yhykes: <pre><p>I uh, was very shocked for a second that this was being linked to and then realized that it's just Posh. cough.</p></pre>BeardedFists: <pre><p>I appreciate the advice, it sounds like you have some experience to speak from. I will create some demo scripts in powershell and have QA try to break them. That's the true test, how much hair do you pull out when fixing an issue lol.</p></pre>Keith: <pre><p>I would strongly recommend Python for its good Windows support. At a prior job I wrote a Python library for manipulating Excel spreadsheets. You could programmatically add data, generate graphs, etc. You have full access to COM so you can do anything you can do with VBScript, but you get a full programming language.</p>
<p>Because it's dynamically typed and allows lots of syntax overloading, it didn't matter what type of COM object you got back but you could call methods on it, index it, etc.</p>
<p>Edit: but the gentleman who recommends PowerShell has a point. I've never bothered to learn it as I stay as far away from Windows as I can, but it is Windows' native scripting language so it's probably worth investigating and comparing to Python for your needs.</p></pre>grounded042: <pre><p>As much as I like Go, my vote goes to PowerShell for Windows scripts. You can do a lot with it, and the PowerShell ISE is actually decent. I work with mostly Windows servers, and PowerShell is my go to scripting language of choice on them. I can install windows features without messing with dism, work with IIS (I actually hate IIS, but I still have to work with it) relatively easily, and do many many other scripting tasks quite easily. There are also a good number of resources when you Google for PowerShell info. </p></pre>riscie: <pre><p>Why dont you use powershell? Imo its the best scripting language for windows automation...</p></pre>mattn: <pre><ul>
<li><p>Support for Windows environment (mainly IO operations)</p>
<p>afaik, totaly, no problem to do simple things.</p></li>
<li><p>Support for MS Excel interop</p>
<p>See <a href="https://github.com/go-ole/go-ole/blob/master/example/excel/excel.go" rel="nofollow">https://github.com/go-ole/go-ole/blob/master/example/excel/excel.go</a></p></li>
<li><p>Script linking / calling classes and functions from separate scripts</p>
<p>if you will do "go run", it mean that.</p></li>
<li><p>GUI support or existing GUI libraries</p>
<p>See <a href="https://github.com/avelino/awesome-go/#gui" rel="nofollow">https://github.com/avelino/awesome-go/#gui</a></p></li>
<li><p>Decent debugging tools</p>
<p>gdb</p></li>
</ul></pre>Streamweaver66: <pre><p>I would echo statements on Python as the go to for this or even .Net. Right tool for the right job and all that.</p></pre>Growlizing: <pre><p>I love Go, but this sounds more like .Net land. .Net with Powershell. It seems like the correct tool for this job.</p>
<p>No idea how you would integrate Go with excel and windows eco-system GUIs.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传