TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Rf: an experimental refactoring tool for Go

241 点作者 robfig将近 4 年前

9 条评论

CGamesPlay将近 4 年前
This seems pretty cool, from looking over the documentation. Two things I wish I could do that I don&#x27;t see in the documentation:<p>- Replace an import with another import. This is used when forking a go package.<p>- Rename a package.<p>It&#x27;s also pretty unclear from the documentation which operations are &quot;UNIMPLEMENTED&quot;, since the label simply falls directly between two different operations. It would be nice if this were made more explicit.
评论 #27271403 未加载
omeze将近 4 年前
I used to joke at work that the fastest, simplest way to get promoted to a staff engineering position was to finish a 1 yr refactor.<p>Getting existing codebases to do new things is hard, and most of enterprise software engineering is basically &quot;rework this API (in the general sense, not web-API sense) for a new product use case&quot;.<p>This tool seems to borrow the philosophy of Go&#x27;s keeping the language simple, with the tradeoff of a more complex (but fairly well supported) ecosystem to account for missing language features.<p>IME, Golang (some would say paradoxically due to a lack of generics) is one of the best languages to refactor because of:<p>- Forced error handling semantics so that unhappy paths are easily enumerated<p>- Tooling like `rdep` to quickly grok the impact of a package refactor<p>- String templates&#x2F;codegen being a first-class &quot;blessed&quot; part of the ecosystem (i.e. you can find tooling by the Go team as a reference when writing your own)<p>Some would balk at things like codegen being how Go handles this, but for the iteration loops at most companies at scale (where a few tools to do codegen are written &amp; maintained by one team and consumed by others) it works well. For paradigms where you want everyone to contribute to the tooling, it works slightly less well since the barrier of understanding the ecosystem is greater than just understanding the language. Nevertheless, it seems to be the right tradeoff for most enterprise use cases.
评论 #27272226 未加载
评论 #27271789 未加载
评论 #27271864 未加载
评论 #27275406 未加载
iddan将近 4 年前
A similar concept named &quot;Tactics&quot; was explored in Haskell. <a href="https:&#x2F;&#x2F;reasonablypolymorphic.com&#x2F;blog&#x2F;towards-tactics&#x2F;" rel="nofollow">https:&#x2F;&#x2F;reasonablypolymorphic.com&#x2F;blog&#x2F;towards-tactics&#x2F;</a> HN Discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24759649" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24759649</a>
评论 #27275761 未加载
jchw将近 4 年前
I hope more refactoring tools come into existence in the future. Right now, writing transforms similar to this complexity using Clang would require a fairly large amount of boilerplate code, implementing at least some AST matching code and wrapping it into a frontend action. While having this for Go is good, I hope it grows and inspires others to do similar things in other languages, the same way gofmt once did.
评论 #27271113 未加载
评论 #27271556 未加载
AYBABTME将近 4 年前
I think this is cool but I wonder what the expected API surface for editor integrations (with mouse-click menu selection to apply a refactor) would work. Would editors code-generate this mini scripting language? Or will there be a more abstract way of providing the same intention to the tool? If editor integrations are expected to send the script-snippets, will there be facilities for programmatically generating valid script snippets?
alert0将近 4 年前
I&#x27;ve always wanted a tool that finds duplicate code (with minor variable name differences) so I can factor it out. Often when prototyping I&#x27;ll copy a function thinking it will change a lot or maybe just not knowing what will change. As the application matures I&#x27;ll go back and clean these up but it shouldn&#x27;t be too hard for a tool to identify.
评论 #27272415 未加载
评论 #27272457 未加载
评论 #27272486 未加载
konart将近 4 年前
Shouldn&#x27;t this be part of gopls or something?
评论 #27275976 未加载
dorian-graph将近 4 年前
A similar, but general purpose, tool to this is <a href="https:&#x2F;&#x2F;comby.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;comby.dev&#x2F;</a>.<p>I&#x27;ve used it before locally for some structural code changes. The author is super helpful&#x2F;responsive too.
MorganGallant将近 4 年前
I wonder if this is some sort of precursor work for the generics release? Feels like gofmt -r on steroids, and could be eventually used to do large scale transformations to the standard library?