Skip to content

Commit 51a9e62

Browse files
devlooped-botkzu
authored andcommitted
+Mᐁ includes
1 parent f7519ef commit 51a9e62

1 file changed

Lines changed: 171 additions & 0 deletions

File tree

src/go/readme.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,178 @@
33
[![GitHub](https://img.shields.io/badge/-source-181717.svg?logo=GitHub)](https://github.com/devlooped/go)
44

55
<!-- include ../../readme.md#content -->
6+
<!-- #content -->
7+
8+
## What is `go#`?
9+
10+
`go#` (go sharp) lets you run `.cs` files directly, like scripts, while still getting the full power of the .NET SDK (dependencies, compilation, AOT, etc.).
11+
12+
It shines for:
13+
- Quick one-off tools and prototypes
14+
- File-based apps without a `.csproj`
15+
- Fast iteration with smart caching (subsequent runs are near-instant when nothing changed)
16+
- Easy sharing of small utilities (just the `.cs` file)
17+
18+
19+
## Usage
20+
21+
```console
22+
# Run a file
23+
dnx go app.cs
24+
25+
# Pass arguments to your app
26+
dnx go app.cs -- arg1 arg2
27+
28+
# Pass arguments to the underlying `dotnet publish`
29+
dnx go app.cs /p:MyProp=true -- arg1 arg2
30+
```
31+
32+
The default mode publishes the app with native AOT and then runs the resulting executable,
33+
with smart up-to-date checks of every C# file used to build the app (including
34+
`#include` and `#ref` directives, transitively).
35+
36+
Use `--r2r` when your app needs more dynamic .NET features (reflection, dynamic loading, etc.)
37+
that native AOT does not support, while still keeping most publish optimizations:
38+
39+
```console
40+
dnx go app.cs --r2r
41+
42+
# Pass arguments to your app
43+
dnx go app.cs --r2r -- arg1 arg2
44+
```
45+
46+
This publishes with `/p:PublishAot=false` and `/p:PublishReadyToRun=true`.
47+
An equivalent `--aot` switch is not needed since native AOT is the default for file-based apps.
48+
49+
A dev mode is also available for faster iteration, which skips the publish step
50+
and runs the app directly from the build output without the optimizations
51+
applied by dotnet to published executables (i.e. AOT, RID-specific optimizations):
52+
53+
```console
54+
dnx go dev app.cs
55+
56+
# Pass arguments to your app
57+
dnx go dev app.cs -- arg1 arg2
58+
59+
# Pass arguments to the underlying `dotnet run`
60+
dnx go dev app.cs /p:Configuration=Release -- arg1 arg2
61+
```
62+
63+
## Cache and cleaning
64+
65+
`go#` caches build and publish outputs per entry-point file under the
66+
user's temp area (`%TEMP%\dotnet\go` on Windows,
67+
`~/.local/share/dotnet/go` on Linux, `~/Library/Application Support/dotnet/go` on macOS), which is what makes
68+
unchanged re-runs near-instant.
69+
70+
```console
71+
# Delete the cached artifacts for a single app (next run rebuilds)
72+
dnx go clean app.cs
73+
74+
# Delete the cached artifacts for all apps
75+
dnx go clean --all
76+
```
77+
78+
Caches are also cleaned automatically: at most once every couple of days,
79+
`go#` removes cache directories that haven't been used for a while, in a
80+
detached background process. Apps you run regularly are never affected.
81+
82+
## Performance
83+
84+
The main advantage of `go#` is **fast unchanged re-runs**.
85+
The two core scenarios for `go#` file-based apps are:
86+
* While tweaking 👉 `dnx go dev app.cs` (optimized `dotnet run app.cs`)
87+
* When stable 👉 `dnx go app.cs` (optimized `dotnet publish app.cs; app[.exe]`)
88+
89+
The numbers below showcase both scenarios, comparing `go#` to `dotnet run` and
90+
`dotnet publish` for a file-based app with different combinations of `#include` and `#ref` directives.
91+
92+
<!-- ./artifacts/results/Benchmarks-report-github.md -->
93+
```
94+
95+
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8737/25H2/2025Update/HudsonValley2)
96+
AMD Ryzen AI 9 HX 370 w/ Radeon 890M 2.00GHz, 1 CPU, 24 logical and 12 physical cores
97+
.NET SDK 11.0.100-preview.5.26302.115
98+
[Host] : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v4
99+
Job-TASYDQ : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v4
100+
101+
InvocationCount=1 IterationCount=3 LaunchCount=1
102+
UnrollFactor=1 WarmupCount=1
103+
104+
```
105+
| Method | Sample | Mean | Error | StdDev |
106+
|----------------- |---------------- |-----------:|------------:|---------:|
107+
| **&#39;dnx go&#39;** | **#include** | **483.2 ms** | **85.70 ms** | **4.70 ms** |
108+
| &#39;dotnet publish&#39; | #include | 3,302.0 ms | 1,003.60 ms | 55.01 ms |
109+
| &#39;dnx go dev&#39; | #include | 500.1 ms | 250.72 ms | 13.74 ms |
110+
| &#39;dotnet run&#39; | #include | 475.6 ms | 100.88 ms | 5.53 ms |
111+
| **&#39;dnx go&#39;** | **#include + #ref** | **481.4 ms** | **236.79 ms** | **12.98 ms** |
112+
| &#39;dotnet publish&#39; | #include + #ref | 3,474.3 ms | 391.66 ms | 21.47 ms |
113+
| &#39;dnx go dev&#39; | #include + #ref | 498.3 ms | 290.97 ms | 15.95 ms |
114+
| &#39;dotnet run&#39; | #include + #ref | 1,426.7 ms | 318.56 ms | 17.46 ms |
115+
| **&#39;dnx go&#39;** | **#ref** | **487.1 ms** | **140.05 ms** | **7.68 ms** |
116+
| &#39;dotnet publish&#39; | #ref | 3,509.4 ms | 616.31 ms | 33.78 ms |
117+
| &#39;dnx go dev&#39; | #ref | 505.2 ms | 264.59 ms | 14.50 ms |
118+
| &#39;dotnet run&#39; | #ref | 1,413.9 ms | 267.93 ms | 14.69 ms |
119+
| **&#39;dnx go&#39;** | **minimal** | **480.8 ms** | **486.66 ms** | **26.68 ms** |
120+
| &#39;dotnet publish&#39; | minimal | 3,237.4 ms | 567.55 ms | 31.11 ms |
121+
| &#39;dnx go dev&#39; | minimal | 488.4 ms | 209.11 ms | 11.46 ms |
122+
| &#39;dotnet run&#39; | minimal | 482.5 ms | 507.46 ms | 27.82 ms |
123+
124+
<!-- ./artifacts/results/Benchmarks-report-github.md -->
125+
126+
<!-- #content -->
127+
<!-- ../../readme.md#content -->
6128

7129
<!-- include https://github.com/devlooped/.github/raw/main/osmf.md -->
130+
## Open Source Maintenance Fee
131+
132+
To ensure the long-term sustainability of this project, users of this package who generate
133+
revenue must pay an [Open Source Maintenance Fee](https://opensourcemaintenancefee.org).
134+
While the source code is freely available under the terms of the [License](license.txt),
135+
this package and other aspects of the project require [adherence to the Maintenance Fee](osmfeula.txt).
136+
137+
To pay the Maintenance Fee, [become a Sponsor](https://github.com/sponsors/devlooped) at the proper
138+
OSMF tier. A single fee covers all of [Devlooped packages](https://www.nuget.org/profiles/Devlooped).
139+
140+
<!-- https://github.com/devlooped/.github/raw/main/osmf.md -->
8141

9142
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
143+
# Sponsors
144+
145+
<!-- sponsors.md -->
146+
[![Clarius Org](https://avatars.githubusercontent.com/u/71888636?v=4&s=39 "Clarius Org")](https://github.com/clarius)
147+
[![MFB Technologies, Inc.](https://avatars.githubusercontent.com/u/87181630?v=4&s=39 "MFB Technologies, Inc.")](https://github.com/MFB-Technologies-Inc)
148+
[![SandRock](https://avatars.githubusercontent.com/u/321868?u=99e50a714276c43ae820632f1da88cb71632ec97&v=4&s=39 "SandRock")](https://github.com/sandrock)
149+
[![DRIVE.NET, Inc.](https://avatars.githubusercontent.com/u/15047123?v=4&s=39 "DRIVE.NET, Inc.")](https://github.com/drivenet)
150+
[![Keith Pickford](https://avatars.githubusercontent.com/u/16598898?u=64416b80caf7092a885f60bb31612270bffc9598&v=4&s=39 "Keith Pickford")](https://github.com/Keflon)
151+
[![Thomas Bolon](https://avatars.githubusercontent.com/u/127185?u=7f50babfc888675e37feb80851a4e9708f573386&v=4&s=39 "Thomas Bolon")](https://github.com/tbolon)
152+
[![Kori Francis](https://avatars.githubusercontent.com/u/67574?u=3991fb983e1c399edf39aebc00a9f9cd425703bd&v=4&s=39 "Kori Francis")](https://github.com/kfrancis)
153+
[![Reuben Swartz](https://avatars.githubusercontent.com/u/724704?u=2076fe336f9f6ad678009f1595cbea434b0c5a41&v=4&s=39 "Reuben Swartz")](https://github.com/rbnswartz)
154+
[![Jacob Foshee](https://avatars.githubusercontent.com/u/480334?v=4&s=39 "Jacob Foshee")](https://github.com/jfoshee)
155+
[![](https://avatars.githubusercontent.com/u/33566379?u=bf62e2b46435a267fa246a64537870fd2449410f&v=4&s=39 "")](https://github.com/Mrxx99)
156+
[![Eric Johnson](https://avatars.githubusercontent.com/u/26369281?u=41b560c2bc493149b32d384b960e0948c78767ab&v=4&s=39 "Eric Johnson")](https://github.com/eajhnsn1)
157+
[![Jonathan ](https://avatars.githubusercontent.com/u/5510103?u=98dcfbef3f32de629d30f1f418a095bf09e14891&v=4&s=39 "Jonathan ")](https://github.com/Jonathan-Hickey)
158+
[![Ken Bonny](https://avatars.githubusercontent.com/u/6417376?u=569af445b6f387917029ffb5129e9cf9f6f68421&v=4&s=39 "Ken Bonny")](https://github.com/KenBonny)
159+
[![Simon Cropp](https://avatars.githubusercontent.com/u/122666?v=4&s=39 "Simon Cropp")](https://github.com/SimonCropp)
160+
[![agileworks-eu](https://avatars.githubusercontent.com/u/5989304?v=4&s=39 "agileworks-eu")](https://github.com/agileworks-eu)
161+
[![Zheyu Shen](https://avatars.githubusercontent.com/u/4067473?v=4&s=39 "Zheyu Shen")](https://github.com/arsdragonfly)
162+
[![Vezel](https://avatars.githubusercontent.com/u/87844133?v=4&s=39 "Vezel")](https://github.com/vezel-dev)
163+
[![ChilliCream](https://avatars.githubusercontent.com/u/16239022?v=4&s=39 "ChilliCream")](https://github.com/ChilliCream)
164+
[![4OTC](https://avatars.githubusercontent.com/u/68428092?v=4&s=39 "4OTC")](https://github.com/4OTC)
165+
[![domischell](https://avatars.githubusercontent.com/u/66068846?u=0a5c5e2e7d90f15ea657bc660f175605935c5bea&v=4&s=39 "domischell")](https://github.com/DominicSchell)
166+
[![Adrian Alonso](https://avatars.githubusercontent.com/u/2027083?u=129cf516d99f5cb2fd0f4a0787a069f3446b7522&v=4&s=39 "Adrian Alonso")](https://github.com/adalon)
167+
[![torutek](https://avatars.githubusercontent.com/u/33917059?v=4&s=39 "torutek")](https://github.com/torutek)
168+
[![Ryan McCaffery](https://avatars.githubusercontent.com/u/16667079?u=c0daa64bb5c1b572130e05ae2b6f609ecc912d4d&v=4&s=39 "Ryan McCaffery")](https://github.com/mccaffers)
169+
[![Seika Logiciel](https://avatars.githubusercontent.com/u/2564602?v=4&s=39 "Seika Logiciel")](https://github.com/SeikaLogiciel)
170+
[![Andrew Grant](https://avatars.githubusercontent.com/devlooped-user?s=39 "Andrew Grant")](https://github.com/wizardness)
171+
[![eska-gmbh](https://avatars.githubusercontent.com/devlooped-team?s=39 "eska-gmbh")](https://github.com/eska-gmbh)
172+
[![Geodata AS](https://avatars.githubusercontent.com/u/5946299?v=4&s=39 "Geodata AS")](https://github.com/geodata-no)
173+
174+
175+
<!-- sponsors.md -->
176+
[![Sponsor this project](https://avatars.githubusercontent.com/devlooped-sponsor?s=118 "Sponsor this project")](https://github.com/sponsors/devlooped)
177+
178+
[Learn more about GitHub Sponsors](https://github.com/sponsors)
179+
180+
<!-- https://github.com/devlooped/sponsors/raw/main/footer.md -->

0 commit comments

Comments
 (0)