Syntax Higlighters

Posted on Jun 13, 2020

Python

def sum(a,b):
    return a+b
print(f'The Sum of 4 and 5 is {sum(4,5)}')

海明威的妻子
海明威的妻子

JavaScript

Tayen

Xina

# ==========================================================
# Flutter部署 (Windows)
# ==========================================================

$FlutterZipUrl = "https://storage.flutter-io.cn/flutter_infra_release/releases/stable/windows/flutter_windows_3.38.5-stable.zip"
$InstallDir = Get-Location
$FlutterRoot = Join-Path $InstallDir "flutter"
$FlutterBin = Join-Path $FlutterRoot "bin"

Write-Host "--- 正在初始化 Flutter 部署环境 ---" -ForegroundColor Cyan

# 1. 配置国内镜像环境变量 (当前进程有效)
Write-Host "[1/5] 配置国内镜像..."
$env:PUB_HOSTED_URL = "https://pub.flutter-io.cn"
$env:FLUTTER_STORAGE_BASE_URL = "https://storage.flutter-io.cn"

# 2. 检测是否已安装
if (Test-Path $FlutterBin) {
    Write-Host "检测到 Flutter 已存在于 $FlutterRoot,跳过下载。" -ForegroundColor Yellow
} else {
    Write-Host "[2/5] 正在下载 Flutter SDK (这可能需要几分钟)..." -ForegroundColor White
    $ZipFile = Join-Path $InstallDir "flutter_sdk.zip"
    Invoke-WebRequest -Uri $FlutterZipUrl -OutFile $ZipFile
    
    Write-Host "[3/5] 正在解压..." -ForegroundColor White
    Expand-Archive -Path $ZipFile -DestinationPath $InstallDir -Force
    Remove-Item $ZipFile
}

# 3. 动态配置环境变量
Write-Host "[4/5] 配置临时环境变量..."
if ($env:Path -notlike "*$FlutterBin*") {
    $env:Path = "$FlutterBin;" + $env:Path
}

# 4. 启用 Windows 桌面支持 (公共电脑最快调试方案)
Write-Host "[5/5] 开启 Windows 桌面开发支持..."
flutter config --enable-windows-desktop --no-analytics

# 5. 验证与诊断
Write-Host "`n--- 环境验证 ---" -ForegroundColor Cyan
flutter --version

Write-Host "`n[提示] 环境已就绪!" -ForegroundColor Green
Write-Host "由于是公共电脑,请在此 PowerShell 窗口内运行 flutter 命令。"
Write-Host "你可以输入 'flutter doctor' 查看完整报告。"

Go

package main

import (
	"fmt"
)

func addition(a int, b int) int {
	return a + b
}
func main() {
	x := addition(4, 5)
	fmt.Println(x)
}