LoginSignup
12
12

More than 5 years have passed since last update.

Goでファイル名から拡張子を取りだす

Last updated at Posted at 2014-04-24

stringでも"hoge"[0:] みたいな記法ができて便利
(他にいい方法があるかもしれない)

package main

import "strings"

func main(){
    filename := "hoge.piyo.moge.js"
    pos := strings.LastIndex(filename, ".")

    println(filename[pos:]) // .js
}
12
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12