[feat] 新增 GetAbsPath 方法
This commit is contained in:
		
							parent
							
								
									f3d4de13b2
								
							
						
					
					
						commit
						9426da7d6b
					
				@ -2,6 +2,8 @@ package support
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"unsafe"
 | 
						"unsafe"
 | 
				
			||||||
@ -161,3 +163,13 @@ func UcFirst(s string) string {
 | 
				
			|||||||
func StudlyCase(s string) string {
 | 
					func StudlyCase(s string) string {
 | 
				
			||||||
	return strings.Replace(strings.Title(strings.Replace(s, "-", " ", -1)), " ", "", -1)
 | 
						return strings.Replace(strings.Title(strings.Replace(s, "-", " ", -1)), " ", "", -1)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetAbsPath(s string) string {
 | 
				
			||||||
 | 
						if strings.HasPrefix(s, "/") {
 | 
				
			||||||
 | 
							return s
 | 
				
			||||||
 | 
						} else if dir, err := os.Getwd(); err == nil {
 | 
				
			||||||
 | 
							return filepath.Join(dir, s)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return s
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user