Instantly convert code snippets from Swift to Go with our free online code converter. Transform your code easily and accurately.
Experience the full potential of AI-driven code conversion and transformation!
We prioritize your code's security and privacy. Your code is not stored on our servers and is only temporarily processed for conversion. We use OpenAI's secure servers for the conversion process, ensuring your code remains confidential.
Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community.
Go is a statically typed, compiled programming language designed at Google. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.
func isPalindrome(_ str: String) -> Bool {
let clean = str.lowercased().filter { $0.isLetter || $0.isNumber }
return clean == String(clean.reversed())
}
# Example usage
print(isPalindrome("A man, a plan, a canal: Panama")) // true
print(isPalindrome("race a car")) // false
package main
import (
"fmt"
"strings"
"unicode"
)
func isPalindrome(s string) bool {
// Clean the string
clean := strings.Map(func(r rune) rune {
if unicode.IsLetter(r) || unicode.IsNumber(r) {
return unicode.ToLower(r)
}
return -1
}, s)
// Check palindrome
for i := 0; i < len(clean)/2; i++ {
if clean[i] != clean[len(clean)-1-i] {
return false
}
}
return true
}
func main() {
fmt.Println(isPalindrome("A man, a plan, a canal: Panama")) // true
fmt.Println(isPalindrome("race a car")) // false
}
func bubbleSort(_ arr: inout [Int]) {
let n = arr.count
for i in 0..<n {
for j in 0..<(n - i - 1) {
if arr[j] > arr[j + 1] {
arr.swapAt(j, j + 1)
}
}
}
}
# Example usage
var arr = [64, 34, 25, 12, 22, 11, 90]
bubbleSort(&arr)
print(arr)
package main
import "fmt"
func bubbleSort(arr []int) {
n := len(arr)
for i := 0; i < n; i++ {
for j := 0; j < n-i-1; j++ {
if arr[j] > arr[j+1] {
arr[j], arr[j+1] = arr[j+1], arr[j]
}
}
}
}
func main() {
arr := []int{64, 34, 25, 12, 22, 11, 90}
bubbleSort(arr)
fmt.Println(arr)
}
Convert Swift to Python
Open ConverterConvert Swift to JavaScript
Open ConverterConvert Swift to TypeScript
Open ConverterConvert Swift to Java
Open ConverterConvert Swift to C
Open ConverterConvert Swift to C++
Open ConverterConvert Swift to C#
Open ConverterConvert Swift to Dart
Open ConverterConvert Swift to Ruby
Open ConverterConvert Swift to Kotlin
Open ConverterConvert Swift to Rust
Open ConverterConvert Swift to Scala
Open ConverterConvert Swift to PHP
Open ConverterConvert Swift to R
Open ConverterConvert Swift to Haskell
Open ConverterConvert Swift to Julia
Open ConverterConvert Swift to MATLAB
Open ConverterConvert Swift to Lua
Open ConverterConvert Swift to Assembly
Open ConverterConvert Swift to Perl
Open ConverterConvert Swift to Groovy
Open ConverterConvert Swift to Elixir
Open ConverterConvert Swift to F#
Open ConverterConvert Swift to Clojure
Open ConverterConvert Swift to Delphi
Open Converter